dkelosky / jest-stare Goto Github PK
View Code? Open in Web Editor NEWJest HTML Reporter and Results Processor
Home Page: https://dkelosky.github.io/jest-stare/
License: MIT License
Jest HTML Reporter and Results Processor
Home Page: https://dkelosky.github.io/jest-stare/
License: MIT License
Regardless of how JEST_STARE_LOG is set, the onRunStart log seems to be printed out:
jest-stare will write each completed run to <JEST_STARE_DIRECTORY>
It appears to be coming from this line of code:
https://github.com/dkelosky/jest-stare/blob/master/src/reporter/Reporter.ts#L52
An additional statement that comes AFTER jest runs, does seem to be successfully suppressed, so not sure why this one is not.
Using
{
"reporters": [
"default",
["/my-custom-reporter.js", {"banana": "yes", "pineapple": "no"}]
]
}
as mentioned in https://jestjs.io/docs/en/configuration#reporters-array-modulename-modulename-options for jest-stare to set resultDir, doesn't work. It sets it to default jest-stare folder.
Link to raw json distributed with report for a formatted view
Reusing describe statements and nested several levels deep cause some tests to be associated with the wrong describes.
Hi,
I discover the problem (like this) about the newlines encoding in node:11-alpine container.
Since I can not issue PR immediately because I do not have knowledge of javascript and typescreipt, please only report on issues.
Also, this English is from GoogleTranslate, which may be offensive to you. I'm sorry.
~ # yarn jest-stare result.json .
yarn run v1.15.2
$ /root/node_modules/.bin/jest-stare result.json .
': No such file or directory
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
~ # cat -e node_modules/.bin/jest-stare
#!/usr/bin/env node^M$
"use strict";^M$
Object.defineProperty(exports, "__esModule", { value: true });^M$
const CLI_1 = require("./cli/CLI");^M$
const ignoredParmCount = 2;^M$
const args = process.argv.slice(ignoredParmCount);^M$
CLI_1.CLI.run(args);^M$
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiamVzdC1zdGFyZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9qZXN0LXN0YXJlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUNBLG1DQUFnQztBQUVoQyxNQUFNLGdCQUFnQixHQUFHLENBQUMsQ0FBQztBQUMzQixNQUFNLElBQUksR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFDO0FBQ2xELFNBQUcsQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLENBQUMifQ==~ #
~ #
~ # vi node_modules/.bin/jest-stare
~ # cat -e node_modules/.bin/jest-stare
#!/usr/bin/env node$
"use strict";$
Object.defineProperty(exports, "__esModule", { value: true });$
const CLI_1 = require("./cli/CLI");$
const ignoredParmCount = 2;$
const args = process.argv.slice(ignoredParmCount);$
CLI_1.CLI.run(args);$
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiamVzdC1zdGFyZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9qZXN0LXN0YXJlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUNBLG1DQUFnQztBQUVoQyxNQUFNLGdCQUFnQixHQUFHLENBQUMsQ0FBQztBQUMzQixNQUFNLElBQUksR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFDO0FBQ2xELFNBQUcsQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLENBQUMifQ==~ # yarn jest-stare result.json .
yarn run v1.15.2
$ /root/node_modules/.bin/jest-stare result.json .
jest-stare was called with programmatic config
** jest-stare --testResultsProcessor: wrote output report to ./index.html **
Done in 0.48s.
~ #
Hi, I think that a nice improvement would be to be possibility to add and screenshot or any other file (text file ex: test data) to the report.
While configuring jest-stare, I attempted to configure my results directory like so:
"jest-stare": {
"resultDir": "<rootDir>/__tests__/__results__/jest-stare",
"coverageLink": "../unit/coverage/lcov-report/index.html"
}
This leads to the following error:
Error: ENOENT: no such file or directory, mkdir '<rootDir>/'
I believe that this should work in accordance with the jest variable: https://jestjs.io/docs/en/configuration#rootdir-string.
For example, the jest-junit plugin supports this config:
"jest-junit": {
"output": "<rootDir>/__tests__/__results__/junit/junit.xml"
}
Right now, jest-stare can generate Jest JSON results, but it would be nice to suppress the HTML report generation if it is not needed at this time.
I have around 10 pack of scripts each having 5-8 scripts in it. I'm triggering through a batch file. so in that, I only able to get the result of the last pack, so it means it overriding the file not appending. so please help me in this so I can able to solve.
Default resultDir
results in broken file structure when generating the report:
I think this:
https://github.com/dkelosky/jest-stare/blob/v1.6.0/src/processor/Config.ts#L50
should add trailing slash also for default value:
if (config.resultDir == null) {
config.resultDir = Constants.DEFAULT_RESULTS_DIR;
}
config.resultDir = config.resultDir + "/";
The other thing that would be useful is to allow to pass config options in jest config. The following doesn't seem to work:
reporters: [
['jest-stare', {
resultDir: 'report'
}]
];
Hello
I am having an issue while running jest-stare with no results directory present.
Error: ENOENT: no such file or directory, mkdir '__tests__\__results__\unit\html/'
at Object.mkdirSync (fs.js:753:3)
at Function.mkDirSync (C:\XXXXXX\node_modules\jest-stare\lib\utils\IO.js:26:16)
at dirs.forEach (C:\XXXXXX\node_modules\jest-stare\lib\utils\IO.js:34:16)
at Array.forEach (<anonymous>)
at Function.mkdirsSync (C:\XXXXXX\node_modules\jest-stare\lib\utils\IO.js:32:14)
at Processor.generateReport (C:\XXXXXX\node_modules\jest-stare\lib\processor\Processor.js:72:17)
at Processor.generate (C:\XXXXXX\node_modules\jest-stare\lib\processor\Processor.js:44:14)
at Function.run (C:\XXXXXX\node_modules\jest-stare\lib\processor\Processor.js:28:62)
at Reporter.onRunStart (C:\XXXXXX\node_modules\jest-stare\lib\reporter\Reporter.js:16:31)
at C:\XXXXXX\node_modules\@jest\core\build\ReporterDispatcher.js:165:50
Configuration for Jest is done with an env file:
const path = require("path");
const basePath = "./__tests__/__results__/unit";
const testType = "Unit";
module.exports = {
"FORCE_COLOR": "1",
"JEST_STARE_RESULT_DIR": path.join(basePath, "html"),
"JEST_JUNIT_OUTPUT": path.join(basePath, "junit/junit.xml"),
"JEST_JUNIT_ANCESTOR_SEPARATOR": " > ",
"JEST_JUNIT_CLASSNAME": `${testType}.{classname}`,
"JEST_JUNIT_TITLE": "{title}",
"JEST_SUIT_NAME": `${testType} Tests`
}
If I create that directory prior to running jest, the library works.
jest-stare: 1.15.0
jest: 24.7.1
node: 10.15.1
npm: 6.9.0
I am generating html report programmatically. I am setting error when I am loading index.js. Here is the exception
Uncaught TypeError: testResult.testResults is not iterable
at results.testResults.forEach (view.js:273)
at Array.forEach (<anonymous>)
at Function.create (view.js:270)
at Function.show (view.js:67)
at HTMLDocument.document.addEventListener (view.js:50)
There is where I am seeing issue
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Constants_1 = require("../Constants");
const Test_1 = require("../tests/Test");
class TestSuite {
static create(results) {
const elements = [];
const describeLevels = [];
results.testResults.forEach((testResult) => {
let testStatusClass = Constants_1.Constants.PASSED_TEST;
const testSectionStatus = new Map();
for (const result of testResult.testResults) { ------- Exception
Create or link to coverage report
processor(simplePassingTests, { log: false, resultDir: __dirname + "/output" });
writes report to ./jest-stare dir always
Can we have option to output the test results in xml file format, which would be very similar to the output generated in https://github.com/michaelleeallen/jest-junit-reporter.
Some CI/CD tools expects a xml file instead of a json. By having this feature, we could have one single npm module(this one) instead of adding 2 npm dependencies.
When there are failing tests the passing test output is simply noise as I need to get to the failing test output so I can see what I need to correct. I took a look at the code for the "Switch" but I'm not sure what approach you would take given the way this is coded so I was hesitant to create a PR. If this enhancement is something you're open to, I'd be willing to create a PR, but I'd need to know what kind of approach you would want.
At a minimum I would think that this could be a config setting. Also, query params come to mind which would allow the burden of deciding when to set a Switch
state to off to rest with the consumer. Thoughts?
While doing research for unit test HTML reporters I stumbled across jest-stare and I think it looks just fantastic. I'm thinking about introducing jest-stare to my team and including it in our angular/typescript project.
Our project's code coverage is 100%. To achieve this, we have a lot of tests per test suite. This of course makes every report very long.
Here is an example screenshot of a report generated by jest-stare:
As you can see, the scroll bar is very long. I assume it is rather hard to really read through this report and identify the relevant information in this condition.
I'm wondering if it would be possible to enable collapsing/expanding for the various boxes that group the test suites. Maybe together with an collapse all / expand all option.
First of all, thanks for this awesome html reporter!
I get this issue when the image snapshot fails for a different error and this doesn't get picked up by the matcher in jest-stare so the snapshot diff is not copied and rendered.
Error: Expected image to be the same size as the snapshot (2370x6290), but was different (2370x6330).
Relevant code line:
It just needs to additionally match against Expected image to be the same size as the snapshot
.
Thanks.
processor(simplePassingTests, { log: false, resultDir: __dirname + "/output" });
displays a log message still
Instead of the page title being "jest-stare!" and the titlebar reading "jest-stare", it'd be ideal to pass variables in from CI, e.g. the repository and branch name.
e.g.
REPORT_TITLE="${REPO} - Unit Test Report"
REPORT_HEADLINE="${REPO}/${BRANCH}"
Is there a way to combine assets to a single file. Currently mochawesome-report-generator has this option
For describes and tests written in format of multiple levels of describe where tests exists in both levels like:
describe("outer...", ()=> {
it("should be first", () => {
});
describe("inner...", ()=> {
it("should be second", () => {
});
});
});
The jest-stare
report will present the should be second
test before the should be first
test.
A nice feature would be to allow the output to be a zip file. For example, if you need to zip and upload your test results somewhere. Happy to contribute a PR if that fits your road map for this lib.
Sometimes at certain zoom levels failed holder blocks do not show.
It would be nice to collapse large inline diffs (>100 lines) by default and allow the use to expand if desired.
#45 noted that --json creates a different json object to parse. This issue is to track support for that format.
Other reporters such as jest-html-reporter
have an option to include the console output captured by Jest. This is a great feature because you can include important debugging info in the report without cluttering your terminal.
Can we have an option to include that info in a collapsable box at the end of each suite?
The pending function takes in an optional reason string parameter. Would be nice if when the argument passed, it is displayed in the HTML report
I'm on "jest-stare": "^1.25.0",
I would expect to see the following after running my tests:
** jest-stare --reporters: wrote output report to ./jest-stare/index.html **
jest-html-reporter >> Report generated (./jest/reports/jest-html-reporter.html)
This just lets me click the link in the terminal to go to the report rather than dig for it in my file explorer.
However, the jest-stare
message is suppressed when I do the following:
const reporters = [
'default',
['jest-stare', { resultDir: ... }],
['jest-html-reporter', {...}]
]
If it's just
const reporters = [
'default',
'jest-stare',
['jest-html-reporter', {...}]
]
seems to be ok.
Hi,
diff2html has just been updated to remove the vulnerable lodash.merge package
released at 2.9.0, is it possible to update jest-stare to use this?
Thanks
I have a use case when i want the test case to pass even if there is a minor failure which i could log as a warning. I want to attach the text in test result for the user to know that the test case has passed but with warning.
npm run example
When in watch mode, jest seems to look for a file in resultDir, first time it works, then, it keeps adding resultDir to the path and gives errors.
Issue:
src/modules/users/e2e/users.e2e-spec.ts
PASS src/modules/users/users.controller.spec.ts
PASS src/modules/users/users.component.spec.ts
Test Suites: 3 passed, 3 total
Tests: 16 passed, 16 total
Snapshots: 0 total
Time: 0.752s, estimated 1s
Ran all test suites.
----------------------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
----------------------|----------|----------|----------|----------|----------------|
All files | 81.31 | 56.25 | 90 | 92.31 | |
src | 80 | 36.36 | 100 | 90.91 | |
app.module.ts | 80 | 36.36 | 100 | 90.91 | 5 |
src/modules/users | 81.52 | 60.38 | 89.66 | 92.54 | |
users.component.ts | 72.97 | 57.89 | 76.92 | 88.89 | 5,13,14 |
users.controller.ts | 89.74 | 73.91 | 100 | 96.43 | 5 |
users.module.ts | 81.25 | 36.36 | 100 | 91.67 | 5 |
----------------------|----------|----------|----------|----------|----------------|
Watch Usage: Press w to show more.(node:6531) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'reports/reports/reports/reports/js/bootstrap.min.js'
(node:6531) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 33)
(node:6531) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'reports/reports/reports/reports/js/diff2html.min.js'
(node:6531) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 34)
(node:6531) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'reports/reports/reports/reports/js/jquery.min.js'
(node:6531) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 35)
(node:6531) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'reports/reports/reports/reports/js/holder.js'
(node:6531) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 36)
(node:6531) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'reports/reports/reports/reports/css/bootstrap.min.css'
(node:6531) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 37)
(node:6531) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'reports/reports/reports/reports/css/diff2html.min.css'
(node:6531) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 38)
package.json:
"jest": {
"transform": {
"^.+\.tsx?$": "ts-jest"
},
"testRegex": "(/src/.*|(\.|/)(e2e-spec|spec))\.(ts)$",
"testResultsProcessor": "jest-stare",
"moduleFileExtensions": [
"ts",
"js"
],
"collectCoverage": true,
"testDirectoryName": "src",
"testFileExtensions": [
"ts"
],
"modulePathIgnorePatterns": [
"/.idea/",
"/coverage/",
"/reports/"
],
"watchPathIgnorePatterns": [
"/.idea/",
"/coverage/",
"/reports/"
]
},
"jest-stare": {
"resultDir": "reports",
"log": false
}
This data causes a snapshot difference but is not recognized as a "diff" and so does not generate side-by-side report.
Generate via node lib/jest-stare __tests__/data/failSnapshotDiff.json
and see Status.test.ts
Hi guys.
I'm hitting this error: Cannot find module './doc/IJestStareConfig'
Any help would be greatly appreciated.
Error: Cannot find module './doc/IJestStareConfig' at Function.Module._resolveFilename (module.js:543:15) at Function.Module._load (module.js:470:25) at Module.require (module.js:593:17) at require (internal/module.js:11:18) at Object.<anonymous> (/node_modules/jest-stare/lib/processor/Config.js:5:28) at Module._compile (module.js:649:30) at Object.Module._extensions..js (module.js:660:10) at Module.load (module.js:561:32) at tryModuleLoad (module.js:501:12) at Function.Module._load (module.js:493:3) error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
It would be great to check visual regression just like snapshot diff :D
It would be nice if in the html output, the test file names were relative to the project root. This would remove some clutter in the ui when running from a CI/CD environment.
For Example:
In my jenkins pipeline, jest-stare reports that tests are named like: /home/jenkins/workspace/ce_create-performance-class-QQJA254Q6QB2QLHTANX2367QN4XUUAEKPDFVBIZLHLOLVMI2VHHA/src/performance/manager/__tests__/PerformanceApiManager.unit.test.ts
This string could be shortened to: src/performance/manager/__tests__/PerformanceApiManager.unit.test.ts
For reference, here's how the former path looks in the UI:
and what it could look like with the changes:
Hey,
one of last updates allowed to config via. jest config file. For this config:
reporters: [
"default",
[
"jest-stare",
{
resultDir: "tests/unit/results",
reportTitle: "...Test results",
reportHeadline: "...",
coverageLink: "../../coverage/index.html"
}
],
I am getting two reports: one in under /tests/unit/results and second /jest-stare
Could be nice to have the date and time of the test run logged in the reporter
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.