Skip to content
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

feat: add a seed value to test runs #13400

Merged
merged 57 commits into from Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
886a1e2
planned documentation
Joshua-Hwang Oct 6, 2022
d551da5
expose seed to runtime
Joshua-Hwang Oct 6, 2022
4e44bef
WIP documentation
Joshua-Hwang Oct 6, 2022
0877be4
integration tests for passing the seed to runtime
Joshua-Hwang Oct 6, 2022
d1f5311
seed is generated when not supplied
Joshua-Hwang Oct 6, 2022
49c060f
fixed other tests
Joshua-Hwang Oct 6, 2022
bc8b4eb
improved documentation
Joshua-Hwang Oct 6, 2022
c5ca4d7
Merge branch 'facebook:main' into feat-get-seed
Joshua-Hwang Oct 6, 2022
fecf106
added copyright
Joshua-Hwang Oct 6, 2022
c39e63f
added replace seed function
Joshua-Hwang Oct 7, 2022
923f556
added Seed to reporter
Joshua-Hwang Oct 7, 2022
07f7b55
fixed some e2e tests for new Seed report
Joshua-Hwang Oct 7, 2022
3987577
updated line number of e2e test
Joshua-Hwang Oct 7, 2022
dda334e
updated snapshots
Joshua-Hwang Oct 7, 2022
3c61bc2
Merge branch 'main' of https://github.com/facebook/jest into feat-get…
jhwang98 Oct 7, 2022
08e53ac
added changelog
jhwang98 Oct 7, 2022
e848382
fixed e2e tests
jhwang98 Oct 7, 2022
9424589
lint fix
Joshua-Hwang Oct 7, 2022
83f5e9a
updated further snapshots
Joshua-Hwang Oct 7, 2022
bfcc0b4
removed seed from initial options
Joshua-Hwang Oct 8, 2022
3e78642
added typing tests
Joshua-Hwang Oct 8, 2022
ba7f269
documentation and messages made more clear
Joshua-Hwang Oct 8, 2022
40047fe
added --showSeed arg
Joshua-Hwang Oct 8, 2022
6730725
moved seed from environment to ctor
Joshua-Hwang Oct 8, 2022
589d434
snapshots updated
Joshua-Hwang Oct 8, 2022
4eafd79
fixed up e2e tests
Joshua-Hwang Oct 8, 2022
ebdf7cb
added new e2e test for --showSeed
Joshua-Hwang Oct 8, 2022
116bdca
linting fix
Joshua-Hwang Oct 8, 2022
b7d5faa
Merge branch 'feat-get-seed' of github.com:jhwang98/jest into feat-ge…
Joshua-Hwang Oct 8, 2022
c7d196a
added showseed docs
Joshua-Hwang Oct 8, 2022
d2af3a6
showSeed is the only way to print the seed
Joshua-Hwang Oct 8, 2022
2ea7dc6
e2e tests related are updated
Joshua-Hwang Oct 8, 2022
b9b8abf
snapshots updated
Joshua-Hwang Oct 8, 2022
679521b
added showSeed to config
Joshua-Hwang Oct 8, 2022
adda4f7
added e2e test for showSeed config
Joshua-Hwang Oct 8, 2022
01ac6f3
documented showSeed config
Joshua-Hwang Oct 8, 2022
71c04c4
updated docs
Joshua-Hwang Oct 8, 2022
1fee0a7
globalConfig passed instead and error thrown when seed is not present
Joshua-Hwang Oct 8, 2022
7b97aab
lint fix
Joshua-Hwang Oct 8, 2022
076eb02
replace Date.now
Joshua-Hwang Oct 8, 2022
d0eed4a
added showSeed test
Joshua-Hwang Oct 9, 2022
523b995
use jest.useFakeTimer instead
Joshua-Hwang Oct 9, 2022
1328b7b
removed optional chaining
Joshua-Hwang Oct 9, 2022
1aae653
lint fix and error now has message
Joshua-Hwang Oct 9, 2022
d568629
clarified docs
Joshua-Hwang Oct 9, 2022
e246b8a
Changelog updated
Joshua-Hwang Oct 9, 2022
3efe6fc
tweak changelog
SimenB Oct 9, 2022
0fb3e79
tweak link
SimenB Oct 9, 2022
d023a21
run same integration test
SimenB Oct 9, 2022
535730b
do not use snapshots in tests
SimenB Oct 9, 2022
3cb272b
tweak doc
SimenB Oct 9, 2022
b8a70eb
test bounds of seed
SimenB Oct 9, 2022
b2021e5
no hooks
SimenB Oct 9, 2022
91212a2
remove unused optional
SimenB Oct 9, 2022
ed5f9c1
oops
SimenB Oct 9, 2022
157ea7e
Merge branch 'main' into feat-get-seed
SimenB Oct 9, 2022
cf0230c
prettier
SimenB Oct 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/CLI.md
Expand Up @@ -352,7 +352,7 @@ The default regex matching works fine on small runs, but becomes slow if provide

### `--seed=<num>`

Sets a seed value that can be retrieved in a test file via [`jest.getSeed()`](JestObjectAPI.md#jestgetseed). The seed value must be between `-0x80000000` and `0x7fffffff` inclusive (`-2147483648` and `2147483647` in decimal).
Sets a seed value that can be retrieved in a test file via [`jest.getSeed()`](JestObjectAPI.md#jestgetseed). The seed value must be between `-0x80000000` and `0x7fffffff` inclusive (`-2147483648` (`-(2 ** 31)`) and `2147483647` (`2 ** 31 - 1`) in decimal).

```bash
jest --seed=1324
Expand Down
3 changes: 3 additions & 0 deletions packages/jest-leak-detector/src/index.ts
Expand Up @@ -14,6 +14,9 @@ import {format as prettyFormat} from 'pretty-format';

const tick = promisify(setImmediate);

const val = -(2 ** 31);
const oval = 2 ** 31 - 1;
jhwang98 marked this conversation as resolved.
Show resolved Hide resolved

export default class LeakDetector {
private _isReferenceBeingHeld: boolean;
private readonly _finalizationRegistry?: FinalizationRegistry<undefined>;
Expand Down