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
Run bun test with the following contents in foo.test.js:
// foo.test.js
import { afterEach, beforeAll, beforeEach, describe, test } from "bun:test";
describe("timeout bugs", async () => {
beforeEach(async () => {
await new Promise((resolve) => setTimeout(resolve, 200));
});
afterEach(async () => {
await new Promise((resolve) => setTimeout(resolve, 200));
});
test(
"first test",
async () => {
await new Promise((resolve) => setTimeout(resolve, 200));
},
{
timeout: 220,
}
);
test(
"second test",
async () => {
await new Promise((resolve) => setTimeout(resolve, 600));
},
{
timeout: 1000,
}
);
test(
"third test",
async () => {
await new Promise((resolve) => setTimeout(resolve, 1000));
},
{
timeout: 1300,
}
);
test(
"fourth test",
async () => {
await new Promise((resolve) => setTimeout(resolve, 1000));
},
{
timeout: 0,
}
);
test(
"the only test that should actually time out",
async () => {
await new Promise((resolve) => setTimeout(resolve, 1000));
},
{
timeout: 100,
}
);
});
What is the expected behavior?
All tests, except for the last test, should succeed:
foo.test.js:
✓ timeout bugs > first test [203.10ms]
✓ timeout bugs > second test [601.91ms]
✓ timeout bugs > third test [1002.49ms]
✓ timeout bugs > fourth test [1004.94ms]
error: Test "the only test that should actually time out" timed out after 100ms
✗ timeout bugs > the only test that should actually time out [103.41ms]
4 pass
1 fail
What do you see instead?
% bun test
bun test v1.1.8 (89d25807)
foo.test.js:
✓ timeout bugs > first test [203.33ms]
error: Test "second test" timed out after 1000ms
✗ timeout bugs > second test [442.58ms]
✓ timeout bugs > third test [1002.92ms]
error: Test "fourth test" timed out after 0ms
✗ timeout bugs > fourth test [1302.32ms]
error: Test "the only test that should actually time out" timed out after 100ms
✗ timeout bugs > the only test that should actually time out [103.78ms]
2 pass
3 fail
Ran 5 tests across 1 files. [3.07s]
Additional information
I have a fix and am about to create a PR for this issue
The text was updated successfully, but these errors were encountered:
Fixesoven-sh#11147
Jest runner would report incorrect timeouts, due to races in the timer
accounting code.
This commit arms and disarms timers before and after every test to
ensure correct timeouts without false-positives.
Fixesoven-sh#11147
Jest runner would report incorrect timeouts, due to races in the timer
accounting code.
This commit arms and disarms timers before and after every test to
ensure correct timeouts without false-positives.
stefreak
changed the title
Bun Jest runner timeout false-negatives and false-positives
Bun Jest runner timeout false-positives
May 17, 2024
stefreak
changed the title
Bun Jest runner timeout false-positives
Bun Jest runner incorrect timeouts
May 17, 2024
What version of Bun is running?
1.1.8+89d25807f
What platform is your computer?
MacOS
What steps can reproduce the bug?
Run
bun test
with the following contents infoo.test.js
:What is the expected behavior?
All tests, except for the last test, should succeed:
What do you see instead?
Additional information
I have a fix and am about to create a PR for this issue
The text was updated successfully, but these errors were encountered: