You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class CustomReporter {
constructor(globalConfig, reporterOptions, reporterContext) {
this._globalConfig = globalConfig;
this._options = reporterOptions;
this._context = reporterContext;
}
// Optionally, reporters can force Jest to exit with non zero code by returning
// an `Error` from `getLastError()` method.
getLastError() {
console.log('this._shouldFail', this._shouldFail);
if (this._shouldFail) {
return new Error('Custom error reported!');
}
}
}
Expected behavior
when test fails., it should print out this._shouldFail true, and also should throw non 0 exit code
Actual behavior
console logged this._shouldFail undefined., and no error was thrown
Version
29.7.0
Steps to reproduce
I have followed the below document to create my own custom reporter,
https://jestjs.io/docs/configuration#custom-reporters
Expected behavior
when test fails., it should print out
this._shouldFail true
, and also should throw non 0 exit codeActual behavior
console logged
this._shouldFail undefined
., and no error was thrownAdditional context
my
jest.config.js
as belowEnvironment
System:
OS: macOS 14.7
CPU: (8) arm64 Apple M3
Binaries:
Node: 18.14.0 - ~/.nvm/versions/node/v18.14.0/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v18.14.0/bin/yarn
npm: 9.3.1 - ~/.nvm/versions/node/v18.14.0/bin/npm
npmPackages:
jest: ^29.7.0 => 29.7.0
The text was updated successfully, but these errors were encountered: