-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
After inside describe is not executed when the before has an error #50842
Labels
test_runner
Issues and PRs related to the test runner subsystem.
Comments
tniessen
added
the
test_runner
Issues and PRs related to the test runner subsystem.
label
Nov 21, 2023
Hey @MoLow, please confirm this issue, if it's a bug I would love to open PR for this. |
I would expect this to be the behavior, dont think it is a bug |
I'm a bit confused if this would be intended behaviour when in the global scope it behaves differently? @MoLow |
@MoLow JEST describe("test suite", () => {
beforeAll(() => {
console.log("called beofre All");
throw new Error("error");
});
afterAll(() => {
console.log("called after All");
});
it("run test", () => {
expect(1).toBe(1);
});
}); output console.log
called beofre All
at Object.log (test.js:3:13)
console.log
called after All
at Object.log (test.js:7:13)
FAIL ./test.js
test suite
✕ run test (1 ms)
● test suite › run test
error
2 | beforeAll(() => {
3 | console.log("called beofre All");
> 4 | throw new Error("error");
| ^
5 | });
6 | afterAll(() => {
7 | console.log("called after All");
at Object.<anonymous> (test.js:4:11)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 0.352 s
Ran all test suites. Mocha const assert = require("assert");
describe("test suite", function () {
before(() => {
console.log("called beofre All");
throw new Error("error");
});
after(() => {
console.log("called after All");
});
describe("#indexOf()", function () {
it("should return -1 when the value is not present", function () {
assert.equal([1, 2, 3].indexOf(4), -1);
});
});
}); output test suite
called beofre All
1) "before all" hook in "test suite"
called after All
0 passing (3ms)
1 failing
1) test suite
"before all" hook in "test suite":
Error: error
at Context.<anonymous> (test.js:19:11)
at processImmediate (node:internal/timers:466:21)
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version
20.5.1
Platform
mac arm64
Subsystem
test_runner
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
Running the after inside the describe.
What do you see instead?
The after is not executed and the test will never finish because it's not able to close all open handles.
Additional information
Using the global before & after just works as intended
The text was updated successfully, but these errors were encountered: