Coder Social home page Coder Social logo

jest-html-reporter's Introduction

📜

jest-html-reporter

A Jest test results processor for generating a summary in HTML.
Documentation »



Inspired by karma-htmlfile-reporter



Installation

npm:

$ npm install jest-html-reporter --save-dev

yarn:

$ yarn add jest-html-reporter --dev

Usage

Configure Jest to process the test results by adding the following entry to the Jest config (jest.config.json):

"reporters": [
	"default",
	["./node_modules/jest-html-reporter", {
		"pageTitle": "Test Report"
	}]
]

As you run Jest from within the terminal, a file called test-report.html will be created within your root folder containing information about your tests.

There are multiple configuration options available. To read more about these, please refer to the documentation.

Alternative Usage as a Test Results Processor

To run the reporter as a test results processor (after Jest is complete instead of running in parallel), add the following entry to the Jest config (jest.config.json):

{
	"testResultsProcessor": "./node_modules/jest-html-reporter"
}

Note: When running as a testResultsProcessor, the configuration needs be placed within a new file named jesthtmlreporter.config.json residing in the root folder. More information about this can be found in the documentation.

Node Compatibility

This plugin is compatible with Node version ^4.8.3

Configuration

Please note that all configuration properties are optional.

Property Type Description Default
append BOOLEAN If set to true, new test results will be appended to the existing test report false
boilerplate STRING The path to a boilerplate file that should be used to render the body of the test results into. {jesthtmlreporter-content} within the boilerplate will be replaced with the test results null
collapseSuitesByDefault BOOLEAN Whether to collapse test suites by default or not false
customScriptPath STRING Path to a javascript file that should be injected into the test report null
dateFormat STRING The format in which date/time should be formatted in the test report. Have a look in the documentation for the available date format variables. "yyyy-mm-dd HH:MM:ss"
executionTimeWarningThreshold NUMBER The threshold for test execution time (in seconds) in each test suite that will render a warning on the report page. 5 seconds is the default timeout in Jest. 5
includeConsoleLog BOOLEAN If set to true, this will output all triggered console logs for each test suite. Please note that you have to run Jest together with --verbose=false in order to have Jest catch any logs during the tests. false
includeFailureMsg BOOLEAN If this setting is set to true, this will output the detailed failure message for each failed test. false
includeStackTrace BOOLEAN Turning this option off will cut the stack trace from the failure messages. true
includeSuiteFailure BOOLEAN If set to true, this will output the detailed failure message for complete suite failures. false
includeObsoleteSnapshots BOOLEAN If set to true, this will output obsolete snapshot names. false
logo STRING Path to a logo that will be included in the header of the report null
outputPath STRING The path to where the plugin will output the HTML report. The path must include the filename and end with .html "./test-report.html"
pageTitle STRING The title of the document. This string will also be outputted on the top of the page. "Test Suite"
sort STRING Sorts the test results using the given method. Available sorting methods can be found in the documentation. "default"
statusIgnoreFilter STRING A comma-separated string of the test result statuses that should be ignored when rendering the report. Available statuses are: "passed", "pending", "failed" null
styleOverridePath STRING The path to a file containing CSS styles that should override the default styling.* null
useCssFile BOOLEAN If set to true, the CSS styles will link in the current theme's .css file instead of inlining its content on the page false

*The plugin will search for the *styleOverridePath* from the root directory, therefore there is no need to prepend the string with ./ or ../ - You can read more about the themes in the documentation.

Continuous Integration

Configuration may also be performed with environment variables for dynamic file saving paths in different environments. *NOTE: Environment variables will take precedence over configurations set in jesthtmlreporter.config.json and package.json*

Example

Here is an example of dynamically naming your output file and test report title to match your current branch that one might see in a automated deployment pipeline before running their tests.

export BRANCH_NAME=`git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3`
export JEST_HTML_REPORTER_OUTPUT_PATH=/home/username/jest-test-output/test-reports/"$BRANCH_NAME".html
export JEST_HTML_REPORTER_PAGE_TITLE="$BRANCH_NAME"\ Test\ Report

Configuration Environment Variables

The environment variables reflect the configuration options available in JSON format. Please read the documentation for more information on these variables.

jest-html-reporter's People

Contributors

altearius avatar cah4a avatar camflan avatar danielhlane avatar dependabot[bot] avatar dtschust avatar elliotboney avatar georgritzmannrtl avatar ghosharnab avatar hargne avatar katsick avatar lukasmac avatar muckt avatar pascalduez avatar shreypuranik avatar stefanpuia avatar wichopy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jest-html-reporter's Issues

help - how to add "console.log" in the html report?

hi
i would like to add others information in the html report.
for example here
image
i would like to add some comments,
for example
console.log ("user making login is X with password Y)"
for obtaining something like this
image
i'm a bit confused :
who should add this information in the report file? jest ? the report parser? node?
thanks for helping.

Configure output path from CLI

Hello.
Is there any way to configure outputPath from CLI?
I mean something like that:

"scripts": {
        "jenkins:test": "npm run test --testResultsProcessor=jest-html-reporter --outputPath=../../reports"
},

Report not being generated when unit test fails

Hi,
I started using jest-html-reporter and the report is nicely generated when all the tests succeed.
However, I made a small change in one of my tests in order to break it and no report is being generated.

Is there something I may be doing wrong or this can be a bug?
Here is my unit test:

describe('CheckInRedux reducers', () => {

  it('should return the initial state', () => {
    expect(
        reducer(undefined, {})
    ).toEqual(
        {
          checkInConfirmationData: {
            appointments: {},
            equipmentsWithLoadSummary: [],
            equipmentsWithLocationCode: [],
            equipmentsWithSealsInfo: []
          },
          isFetching: true,
          checkInSucceeded: false,
          error: false
        }
    )
  });

The line I changed was isFetching: true, it is supposed to be false.

Thanks in advance.

[UPDATE]
I think the issue is related to having "includeFailureMsg": true in package.json.
Once I set it to false the report was generated but then I cannot see the error message.
Here is a stack trace outputted when includeFailureMsg is set to true.

at Object.<anonymous> (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/App/Redux/CheckIn/CheckInRedux.spec.js:13:1)
    at Object.<anonymous> (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/jest-jasmine2/build/jasmine-async.js:42:32)
    at attemptAsync (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1984:24)
    at QueueRunner.run (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1939:9)
    at /Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1966:16
    at /Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1909:9
    at Object.fn (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/jest-jasmine2/build/jasmine-async.js:68:11)
    at attemptAsync (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1984:24)
    at QueueRunner.run (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1939:9)
    at QueueRunner.execute (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/jest-jasmine2/vendor/jasmine-2.5.2.js:1927:10) at index 7
    at XMLStringifier.module.exports.XMLStringifier.assertLegalChar (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/xmlbuilder/lib/XMLStringifier.js:153:15)
    at XMLStringifier.assertLegalChar (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/xmlbuilder/lib/XMLStringifier.js:4:59)
    at XMLStringifier.module.exports.XMLStringifier.eleText (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/xmlbuilder/lib/XMLStringifier.js:33:19)
    at new XMLText (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/xmlbuilder/lib/XMLText.js:17:35)
    at XMLElement.module.exports.XMLNode.text (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/xmlbuilder/lib/XMLNode.js:165:15)
    at XMLElement.module.exports.XMLNode.node (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/xmlbuilder/lib/XMLNode.js:157:15)
    at XMLElement.module.exports.XMLNode.element (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/xmlbuilder/lib/XMLNode.js:102:28)
    at XMLElement.module.exports.XMLNode.ele (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/xmlbuilder/lib/XMLNode.js:357:19)
    at test.failureMessages.forEach (/Volumes/Unix/workplace/SesameMobile/src/SesameMobile/node_modules/jest-html-reporter/index.js:74:20)
    at Array.forEach (native)

Version 0.5.0 doesn't get properly installed via NPM

Now right after running "npm install", the ./node_modules/jest-html-reporter folder doesn't have /src and /test folders at all:

07/13/2017  10:39 PM    <DIR>          coverage
07/13/2017  10:39 PM                10 .npmignore
07/13/2017  10:39 PM             3,219 CODE_OF_CONDUCT.md
07/13/2017  10:39 PM               218 CONTRIBUTING.md
07/13/2017  10:39 PM               484 jest.config.json
07/13/2017  10:39 PM             1,069 LICENSE
07/13/2017  10:39 PM             5,032 package.json
07/13/2017  10:39 PM             2,178 README.md
07/13/2017  10:39 PM             2,822 test-report.html

But it contains a /coverage folder instead. Version 0.4.1 installs fine.
npm v.4.6.1 , node v.7.9.0

outputPath does not support `<rootDir>` token

It could be a small improvement and we could use a config like this:

{
  // …
  reporters: [
      'default',
      [
        'jest-junit',
        {
          suiteName: 'my unit tests',
          output: '<rootDir>/reports/junit-report.xml',
        },
      ],
      [
        'jest-html-reporter',
        {
          pageTitle: 'my unit tests',
          outputPath: '<rootDir>/reports/output-report.html',
        },
      ],
    ],
}

Customizable Date/Time Format

It should be possible to configure the format of the outputted Date/Time in the test report.

The format should follow the standard Javascript date format.

Emoji characters not supported 😔

Hello there!

First of all thanks for this reporter since it perfectly fit our needs. The only downside i just ran into is that when a test case name has an Emoji in the title it throws an error.

it("Sending an Emoji 😃", function (done) {

The console output:

 PASS  test/integration/Integration.test.js
  POST /myEndpoint
    ✓ Sending an Emoji 😃 (425ms)
...
Ran all test suites.
jest-html-reporter >> Error: Invalid character (�) in string: Sending an Emoji 😃 at index 17

Workaround: For now i removed the Emoji from the 'it'
Version: 2.5.0

reporter mode implemented not properly

I tried 2.0.0 in reporter mode. It doesn't work out as expected.
jest --forceExit will exit before generated report.
I check the sourcecode, in CustomReporter#onRunComplete, actually jest expect the return is a promise and will await the promise before exit.

TypeError: Cannot read property 'append' of undefined after upgrading to 3.0.0

I am using the jest-html-reporter to parse results of unit tests on that I run using command

CI=true react-scripts test  --silent --coverage --noStackTrace --ci --json --testResultsProcessor=./node_modules/jest-html-reporter --outputFile=./coverage/test-results.json"

It worked fine when I was using version 2.7.0, when I upgraded to 3.0.0 I started getting such an error

TypeError: Cannot read property 'append' of undefined
    at h.setupConfig (/Users/mdrzazga/Work/mstrio_ui/production/node_modules/jest-html-reporter/dist/index.js:1:6242)
    at new h (/Users/mdrzazga/Work/mstrio_ui/production/node_modules/jest-html-reporter/dist/index.js:1:1341)
    at f (/Users/mdrzazga/Work/mstrio_ui/production/node_modules/jest-html-reporter/dist/index.js:1:8783)
    at module.exports (/Users/mdrzazga/Work/mstrio_ui/production/node_modules/jest-html-reporter/dist/index.js:1:8911)
    at processResults (/Users/mdrzazga/Work/mstrio_ui/production/node_modules/@jest/core/build/runJest.js:242:47)
    at /Users/mdrzazga/Work/mstrio_ui/production/node_modules/@jest/core/build/runJest.js:429:14
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/mdrzazga/Work/mstrio_ui/production/node_modules/@jest/core/build/runJest.js:148:24)
    at _next (/Users/mdrzazga/Work/mstrio_ui/production/node_modules/@jest/core/build/runJest.js:168:9)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
error Command failed with exit code 1.

When I reverted back to 2.7.0 it was working again.
My package.json:

{
  "name": "project",
  "version": "0.0.1",
  "private": true,
  "homepage": ".",
  "dependencies": {
    "antd": "3.19.1",
    "axios": "0.19.2",
    "i18next": "19.3.4",
    "line-clamp": "1.0.0",
    "moment": "2.24.0",
    "node-sass": "4.13.1",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-i18next": "11.3.4",
    "react-scripts": "3.4.1",
    "set-value": "3.0.1",
    "tabbable": "4.0.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "serve": "serve -s build",
    "test": "react-scripts test --env=jsdom",
    "test:all": "react-scripts test --env=jsdom --watchAll=false",
    "test:ci": "CI=true react-scripts test  --silent --noStackTrace --ci",
    "test:ci_report": "CI=true react-scripts test  --silent --coverage --noStackTrace --ci --json --testResultsProcessor=./node_modules/jest-html-reporter --outputFile=./coverage/test-results.json",
    "coverage": "react-scripts test --env=jsdom --coverage",
    "coverage:all": "react-scripts test --env=jsdom --coverage --watchAll=false",
    "eject": "react-scripts eject",
    "storybook": "start-storybook -p 9009 -s public",
    "storybook:build": "build-storybook -s public",
    "eslint": "eslint ./src --ext .js,.jsx",
    "eslint:report": "eslint ./src --ext .js,.jsx -f html -o ./eslint/index.html"
  },
  "devDependencies": {
    "@storybook/addon-knobs": "5.3.18",
    "@storybook/preset-create-react-app": "2.1.1",
    "@storybook/react": "5.3.18",
    "@storybook/theming": "5.3.18",
    "enzyme": "3.11.0",
    "enzyme-adapter-react-16": "1.15.2",
    "eslint": "6.8.0",
    "eslint-config-airbnb": "18.1.0",
    "eslint-plugin-import": "2.20.2",
    "eslint-plugin-jest": "23.8.2",
    "eslint-plugin-jsx-a11y": "6.2.3",
    "eslint-plugin-react": "7.19.0",
    "eslint-plugin-react-hooks": "3.0.0",
    "jest-html-reporter": "3.0.0",
    "prop-types": "15.7.2",
    "regenerator-runtime": "0.13.5"
  },
  "jest": {
    "collectCoverageFrom": [
      "src/utilities/**/*.{js,jsx}",
      "src/components/**/*.{js,jsx}",
      "!src/components/**/*.stories.{js,jsx}"
    ],
    "transformIgnorePatterns": [
      "/node_modules/(?!(react-dnd))/"
    ]
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie < 11",
    "not op_mini all"
  ]
}

Console Log are always sorted by path, and not by time when they were originated.

In commit b0cbd13 (version 2.7.0) new feaature was added to sort the logs based on file path -

#78
filteredConsoleLogs.logs.sort((a, b) => { if (a.origin < b.origin) { return -1; } if (a.origin > b.origin) { return 1; } return 0; });

While I see this functionality might be useful, for some use cases it is needed to maintain logs in the order they were received ( which is currently matches to the order they were created), If logs are originated in some helper files (not from the JS file with test / describe block), this logic will sort out the logs by path and will break the timeline, which is very useful for to have in the report. It also considers line number, and sorting is done based on the string comparing, not line number comparing.

This behaviour breaks one of the very useful use case for the report.

I suggest not to sort the logs by default (perhaps maybe to have ability to control it with flag or make it pluggable).

hint - how to configure "outputPath" reading from test configuration?

i would like to configure "outputPath" in order to obtain a html file with a name related to the test environment.

this is my jest.config.js file

module.exports = {
    preset: "jest-puppeteer",
    setupFilesAfterEnv: [  // NOT setupFiles
        "./custom-configuration.js",
        "./shared-require.js",
        "jest-allure/dist/setup"
    ],
    "reporters": [
        "default",
        ["./node_modules/jest-html-reporter", {
            "pageTitle": "Test Report",
            "includeFailureMsg": true,
            "includeConsoleLog": true,
            "outputPath":process.env.ENVIRONMENT+"-run.html"
        }],
        ["jest-junit", { outputName: "junitreport.xml" }]
    ],
    moduleNameMapper: { //serve per poter usare $lib
        '^\\$lib\/(.*)': `<rootDir>/lib/$1`,
    },
};

i tried with

 "outputPath":process.env.ENVIRONMENT+"-run.html"

becase i run test with

jest --runInBand --testFailureExitCode 0 --setupFiles=./integration-configuration.js

and the setupFiles contains

process.env.ENVIRONMENT = "integration"

because i use this to load configuration
but process.env.ENVIRONMENT looks "undefined" when getting test result as outputPath was created BEFORE process.env.ENVIRONMENT was set.

another temptative is to read something from the setupFilesAfterEnv script,
but also in this case "outputPath" seems to be created BEFORE "setupFilesAfterEnv" was loaded.

any suggestion to read values from ENV or from setupFilesAfterEnv?

thanksd.

useCssFile and styleOverridePath behavior incorrect

When the reporter is configured to use shouldUseCssFile = true and styleOverridePath=pathToCss, the report html link href is not correct in the generated HTML as it is a relative path.

If for example I have a project structure such as the following

  • project
    jest.config.js
    • src
      reportTheme.css
    • reports

I would configure the jest config in the following way

...
reporters: [
    [
      'jest-html-reporter',
      {
        pageTitle: 'Report',
        outputPath: `./reports/report.html`,
        includeFailureMsg: true,
        useCssFile: true,
        styleOverridePath: 'src/reportTheme.css'
      },
    ]

The report generator will enforce styleOverridePath and check that the file exists whilst the report is being generated even when useCssFile is set true.

The problem arises that the generated link tag href will point to a stylesheet at ${outputPath}/${styleOverridePath} or in this example reports/src/reportTheme.css which will not exist.

This is especially problematic on Jenkins. Using the html publisher plugin takes the generated html artifacts and hosts them at the jenkins instance as opposed to on a build agent with access to all source files, so it's not even possible to use directory traversal relative to the report output directory for theme files.

If I want to point to a CSS file of my choosing, e.g. reportTheme.css (relative to the reports directory) and I manually place the reportTheme.css into the reports directory post report generation, I can't. The report generation will fail with:

Error: Could not locate file: 'reportTheme.css': Error: ENOENT: no such file or directory, open 'reportTheme.css'.

I understand that when we inject the css inline useCssFile = false we inline the CSS and write it into the html generated for the report. We need to check that the file exists, read it and write it into the html.

if useCssFile=true and styleOverridePath is not set, we set the href to the path of the defaultTheme which is resolved by the report generator which will result in correct report generation.

When we have useCssFile=true and styleOverridePath='path/to/file.css' I would expect no file to be read as we are not injecting file contents into the report, only the path we have defined in styleOverridePath.

jest 21 support?

Jest 21 is now out, and it all seems to work okay for me, but package.json is moaning because it isn't an allowed peer dependency.

Can that be relaxed?

Consider adding configuration in reporter declaration

hi,

We can already use the plugin from a jest.config.js as such:

reporters: [
  'default',
  'jest-html-reporter',
]

But we need to create a jesthtmlreporter.config.json.

Desired (fits other reporters config api):

reporters: [
  'default',
  [
    'jest-html-reporter',
    {
      executionMode: 'reporter',
      pageTitle: '...',
      outputPath: '...',
    },
  ],
],

Typo

I did a lot of searching and this was the best reporter by far- thanks! I did, however, find a typo. I uploaded a screenshot of a report showing it. Passed is missing the 'e'. I didn't know where else to mention, so I figured this was the best place.

typo

`includeConsoleLog: true` doesn't report console output for tests

Setup:
Package.json

  "devDependencies": {
    "stuff": "stuff",
    "jest": "23.3.0",
    "jest-html-reporter": "^2.4.2"
  },
"jest": {
    "reporters": [
      "default",
      [
        "./node_modules/jest-html-reporter",
        {
          "pageTitle": "Test Report",
          "includeFailureMsg": true,
          "includeConsoleLog": true,
          "outputPath": "report/index.html"
        }
      ]
    ]
  }

Console output:

  console.log apiAgent.js:17
    Requesting: GET to: /api/cs/v2/resolver?text=Butt%20pain;%20can%E2%80%9A%C3%84%C3%B4t%20lie%20down
(this is a passing test)

  console.log apiAgent.js:17
    Requesting: GET to: /api/cs/v2/resolver?text=neck
(this is a failing test)

  console.log apiAgent.js:27
    Receive body: <html><head><title>Apache Tomcat/7.0.84 - Error report</title><style><!-

The html output only shows:


Test GET endpoint | Test passing one:  | passed in 0.115s
-- | -- | --
Test GET endpoint | Test failing one: neckError: expect(received).toBe(expected) // Object.is equality

No mention of logs on the output

Node 4 support

Hi,

the latest releases are not working anymore on node 4.
I guess there's some unsupported ES6 features being used.

But there's no Changelog, no notice in Readme, nor an engine key in package.json.

Does not generate index.html when there are failing test cases and `includeFailureMsg` = true

With the configuration below, this project only generates build/reports/jest/index.html when all the tests pass. When any tests fail, no report is generated. Jest version is 18.1.0.

  "jest": {
    "verbose": true,
    "testResultsProcessor": "./node_modules/jest-html-reporter"
  },
  "jest-html-reporter": {
    "pageTitle": "Jest Tests",
    "outputPath": "build/reports/jest/index.html",
    "includeFailureMsg": true
  },

jest exists before report is generated

The createReport method returns a promise structure. However, when index.js calls the createReport its not expecting a promise so the execution resumes. The report is never generated because jest exists before the writeFile method is ever called.

Feature Request: Adding Test Content to HTML

Hi,
it would be a handy feature if we can put additional content like return value from a Server into the HTML.

example:

describe('Test', () =>  {
  test('Test', (done) => {
    app.request('192.168.210.111', (err: any, cb: any) => {
      expect(err).toBe(null);
      addContent(this, {
        title: 'Received Message',
        value: cb,
      });
      done();
    });
  });
});

In this example you would see cb below the tested line in the HTML.
I used a similar function with the packet mochawesome.

Validate config via JSON Schema

Hi, I used statusIgnoreFilter option:

  "statusIgnoreFilter": ["passed"],

All of my tests are passed, so I got no html output. Don't think it's good behaviour, cause empty output might be result of error at the same time.

Think is should be simple html with No suites after statusIgnore message into body.

includeFailureMsg not work

I have try all closed issues. I could not see fail test case on html, it only show pass cases.

...
testResultsProcessor: ./node_modules/jest-html-reporter                                                                               
},                                                                                                   
jest-html-reporter: {                                                                                
pageTitle¦: Test Suite,                                                   
outputPath: reports/run-jest-test-report.html,                                                 
includeFailureMsg: true,                                                                         
},
...

In my terminal console, I has these information:

Test Suites: 4 failed, 1 passed, 5 total
Tests:       3 passed, 3 total
Snapshots:   3 passed, 3 total
Time:        6.788s

jest-html-reporter >> TypeError: callback is not a function

The below line of code using jest.spyOn throws a typeError as given in the title.I am unable to suppress the error and html reporter is not generated

it('', () => {

jest.spyOn(fs, 'readFile')
.mockImplementation((_, callback) => callback(null, Buffer.from('Test Read File')));

});

Anyway can i suppress this and generate the reported ?

how can i dynamically change outputPath

I run tests on phpunit and output xml dynamically into a different filename and would like to do same with jest. is there a way to do this?

is this correct way in perl

print "\n"; print "\nRunning Jest";
my $cmd = "export JEST_HTML_REPORTER_OUTPUT_PATH=$dir/docs/library/reports/jest$sprint_release.html && export JEST_HTML_REPORTER_PAGE_TITLE=\"Test_Report$sprint_release\"";
#print "\n$cmd\n";
system("$dir/utils/jest_env && $cmd && jest");

Test Report Themes

Create a few standard test report themes that may be selected via configuration.

sort order not correct for test suite with a lot of tests

While having this order in my test suite:
image
the jest-html-reporter returns the wrong sort order for the individual tests within the suite:
image
This only seem to happen with larger test suites.
note: I only numbered them for this issue ofcourse

Feature Request: Option to exclude generating full html markup

I am injecting the test results into an existing page, so am looking to generate only the test results without the html, meta, style tags, etc. It doesn't cause an actual issue, and i can just override the styles i want to change, but could this be a useful as an option for other users or use cases?

Add separate file to configure this plugin

Hello @Hargne

First of all, thanks for this plugin. It's been helpful to me 👍

I would like to suggest a feature request that allow the configuration to be set in a different file than package.json. It doesn't have to be necessarily the Jest main config, as suggested in #12, but keeping it separate makes sense in the perspective of separation of concerns.

Unfortunately, package .json has become very bloated, where every JS plugin just "injects" its configuration into it, but this pattern only increases the size of the file while keeps it unmaintainable over time, particularly because you can't just split it.

What do you think?

`"includeConsoleLog": true` is not working when `testMatch` or `testPathIgnorePatterns` is added

the console logs are not generated in the html file, when I mention the spec location.

{
  "verbose":true,
  "testMatch":["<rootDir>/**/*.spec.js"],
  "testPathIgnorePatterns": ["/node_modules/", "<rootDir>/src/"],
  "reporters": [
    "default", ["./node_modules/jest-html-reporter", {
        "pageTitle": "Test Report",
        "outputPath": "reports/test-report.html",
        "includeFailureMsg": true,
        "includeConsoleLog": true
    }]
  ]
}

jest --config=jest.config.json

or

{
  "reporters": [
    "default", ["./node_modules/jest-html-reporter", {
        "pageTitle": "Test Report",
        "outputPath": "reports/test-report.html",
        "includeFailureMsg": true,
        "includeConsoleLog": true
    }]
  ]
}

jest path/ --config=jest.config.json

Output:
image

Please clone and run tests from this repo for debugging: https://github.com/prashanth-sams/api-automation-frisby-typescript

Render test results fully in a <table>

We copy/paste our test results into a Microsoft Word document for various reasons. Word is able to handle an incoming html table but each suite is not fully contained within the table - the file name and execution time are inside a div above the table. This ends up poorly formatted.

So our pasted content ends up looking like this:
screen shot 2018-02-07 at 10 06 22 pm

I'm happy to submit a PR if this is an acceptable change.

Change default path of jesthtmlreporter.config.json?

Hi, I would like to change the path of this file, by default it has to be defined in the root, but in my case, I have a directory dedicated only for test configurations to help others working in the same project know where the configuration files for tests are placed, I know that I can inject the options directly into the jest.config.js, but I'm looking the option to keep the files decoupled.

Thanks.

includeConsoleLog not working?

this is my jest.config.js

module.exports = {
    preset: "jest-puppeteer",
    setupFilesAfterEnv: [  // NOT setupFiles
        "./configurazioni/custom-configuration.js",
        "./configurazioni/shared-require.js",
        "jest-allure/dist/setup"
    ],
    "reporters": [
        "default",
        ["./node_modules/jest-html-reporter", {
            "pageTitle": "Test Report",
            "includeFailureMsg": true,
            "includeConsoleLog": true,
            "outputPath":"reports/"+new Date().getDate() + "-" +
                (new Date().getMonth() + 1) + "-"
                + new Date().getFullYear()+ "-"
                + new Date().getHours().toString() + "-"
                + (new Date().getMinutes() + 1 ).toString() + "-"
                + (new Date().getSeconds() + 1 ).toString()
                +"-run.html"
        }],
        ["jest-junit", { outputName: "reports/junitreport.xml" }]
    ],
    moduleNameMapper: { //serve per poter usare $lib
        '^\\$lib\/(.*)': `<rootDir>/lib/$1`,
    },
};

when i run jest ,

file as 23-3-2020-15-33-32-run.html will be created, and this because "outputPath" will be considered.

image

as you can see, there are a lot of console.log in my execution

image

but in the reporter there are any console.log

image

so is "includeConsoleLog" working?

there are my versions

  • jest 24.9
  • jest-html-reporter 2.8.2
  • node 12.13.0

thanks.

jest.config.json is missing

Hi Guys,

I set up a project and included jest and run this command:
npm install jest-html-reporter --save-dev
But I have no "jest.config.json" file..

What can I do, to get this config file?
Or do I have to create it manually?
If yes, where?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.