[jest-circus] missing fail() method
See original GitHub issueThis might be a known issue, but I could not find an existing issue so creating one here 😊 Also, I guess fail() was a bit of an undocumented feature, but we rely on it in our app for some nice developer experience improvements.
💥 Regression Report
After upgrading to Jest v27 (with jest-circus as default) the fail()
method is no longer defined.
ReferenceError: fail is not defined
Last working version
Worked up to version: 26.6.3
Stopped working in version: 27.0.0
Can circumvent in 27.x with testRunner: "jest-jasmine2"
in jest.config.js
To Reproduce
Steps to reproduce the behavior:
- Open a JS project with jest >= 27.0.0
- Write a test that includes a
fail()
method call - Notice that any tests with a call to
fail()
might pass (depending on the structure), and you will see a “fail is not defined” error message in Jest v27 with jest-circus (works correctly with jest-jasmine2)
Expected behavior
Expected fail() to work by default, as before, without any changes to jest.config.js.
Link to repl or repo (highly encouraged)
See this repo for example of the regression: https://github.com/Darep/jest-circus-fail-method
Check the branch jasmine
where the testRunner is changed and the tests run correctly 🙂
The repo also hilights the way we use fail(), just to give some background info & motivation from our use-case 😄
Run npx envinfo --preset jest
Paste the results here:
$ npx envinfo --preset jest
npx: installed 1 in 0.976s
System:
OS: macOS 11.4
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 14.16.1 - ~/n/bin/node
Yarn: 1.21.1 - ~/n/bin/yarn
npm: 6.14.12 - ~/n/bin/npm
npmPackages:
jest: ^27.0.6 => 27.0.6
Issue Analytics
- State:
- Created 2 years ago
- Reactions:66
- Comments:14
Top GitHub Comments
As a result of this issue, there is currently a discrepancy between
@types/jest
, which does definefail
, andjest-circus
, which does not definefail
. Discussion in DefinitelyTypedAs a temporary workaround, you can define your own
fail
function:Any update on this? Many of my integration tests are missing the correct messaging now that this is undefined, and its causing a lot of confusion.