results.success is always false in custom reporter onRunComplete
See original GitHub issueLogging results
from onRunComplete
in MyCustomReporter
shows success
is false
even though all tests pass.
MyCustomReporter
in tests/my-custom-reporter.js
:
class MyCustomReporter {
constructor(globalConfig, options) {
this._globalConfig = globalConfig
this._options = options
}
onRunComplete(contexts, results) {
console.log({ results })
}
}
module.exports = MyCustomReporter
jest config in package.json
"jest": {
"testEnvironment": "node",
"reporters": [
"./tests/my-custom-reporter.js"
]
}
jest output (note success: false
even though numFailedTests: 0
)
$ node ./node_modules/.bin/jest path/to/tests.spec.js
PASS path/to/tests.spec.js
outer
✓ works outer (1ms)
inner
✓ works inner (1ms)
Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 0.352s, estimated 1s
Ran all test suites matching /path\/to\/tests.spec.js/i.
{ results:
{ numFailedTestSuites: 0,
numFailedTests: 0,
numPassedTestSuites: 1,
numPassedTests: 2,
numPendingTestSuites: 0,
numPendingTests: 0,
numRuntimeErrorTestSuites: 0,
numTotalTestSuites: 1,
numTotalTests: 2,
openHandles: [],
snapshot:
{ added: 0,
didUpdate: false,
failure: false,
filesAdded: 0,
filesRemoved: 0,
filesUnmatched: 0,
filesUpdated: 0,
matched: 0,
total: 0,
unchecked: 0,
uncheckedKeysByFile: [],
unmatched: 0,
updated: 0 },
startTime: 1535648815628,
success: false,
testResults: [ [Object] ],
wasInterrupted: false } }
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:8 (3 by maintainers)
Top Results From Across the Web
The 4 stages of flakiness (part 2/3): log failed tests with a Jest ...
Creating a custom reporter would allow to both control the output of the test run ... onRunComplete(contexts, results) { ... success: false,
Read more >Configuring Jest
Whereas a reporter has the ability to receive test results after individual tests and/or test suites are finished. testRunner [string]. Default: jest-circus/ ...
Read more >Unable to make HTTP Post from custom Karma reporter
I have verified that the Axios POST request works by taking the entire contents of the onRunComplete as shown here, putting it in...
Read more >Allure Framework
Allure Framework is a flexible lightweight multi-language test report tool that not only shows a very concise representation of what have ...
Read more >How to setup a custom test reporter for Jest | by Chanon Roy
Here is a simple test reporter that logs test results when the test ... onRunComplete(_: Set<TestContext>, results: AggregatedResult) {
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found this Issue still exists in the latest version. For custom reporter,
success
is set after report generated, so what does thissuccess
symbol mean? I found moveawait this._dispatcher.onRunComplete(contexts, aggregatedResults);
afteraggregatedResults.success = ! ...
will fix the issue, but I’m not sure for other logicsThis issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.