-
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ No timeout for beforeEach or afterEach (#3464)
Timeout must only focus on the code under tests, in other words the predicate. It should not be triggered because of a beforeEach being too long, or a afterEach being too long.
- Loading branch information
Showing
16 changed files
with
633 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
releases: | ||
fast-check: minor | ||
|
||
declined: | ||
- "@fast-check/ava" | ||
- "@fast-check/jest" | ||
- "@fast-check/worker" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as fc from '../../src/fast-check'; | ||
import { seed } from './seed'; | ||
|
||
describe(`Timeout (seed: ${seed})`, () => { | ||
it('should always run beforeEach and afterEach even in case of timeout', async () => { | ||
let numRuns = 0; | ||
const beforeEach = jest.fn().mockResolvedValue(undefined); | ||
const afterEach = jest.fn().mockResolvedValue(undefined); | ||
const out = await fc.check( | ||
fc | ||
.asyncProperty(fc.integer().noShrink(), async (_x) => { | ||
++numRuns; | ||
await new Promise(() => {}); // never ending promise | ||
}) | ||
.beforeEach(beforeEach) | ||
.afterEach(afterEach), | ||
{ timeout: 0 } | ||
); | ||
expect(out.failed).toBe(true); | ||
expect(out.interrupted).toBe(false); | ||
expect(out.numRuns).toBe(1); // only once, it timeouts on first run and then shrink (no-shrink here) | ||
expect(out.numShrinks).toBe(0); | ||
expect(out.numSkips).toBe(0); | ||
expect(numRuns).toBe(1); | ||
expect(beforeEach).toHaveBeenCalledTimes(1); | ||
expect(afterEach).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
Oops, something went wrong.