-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
jest-circus runs children in shuffled order #12922
Changes from 7 commits
e43ca99
bbb1cf3
4c1d07c
99ac4cd
882f920
4df23a9
dc6e64f
3d09cfb
f8860e2
0bec19f
3a1d712
95590dc
14349bd
549988d
4ae8ff2
967b32e
561146c
2f95b65
50bada0
b78fdc2
3f33508
d84caa1
b5c34fe
b9c5139
1b412b4
c45244c
e1e73a0
2152031
6bb9449
164d6fa
79401d1
b6c4da4
19cf2b5
ca3a582
2007d47
9361b80
4d61ba2
a087ce6
7b4bd2b
b175652
54cc38c
974bc5b
b4e448f
816b8e6
4ba33d4
7b40ca5
ebf01d5
9172451
0797346
9c0ff4e
604499d
001d150
30b3452
8661cad
81d526b
825fdd9
7512738
888f565
a6f6982
57e9836
b844e1b
bbc70a1
d4509cb
6ce659d
7bdad9f
08ed42c
5fd2e2a
2bffe52
f5b919c
2688290
ec85fb8
94c0740
e212ed9
5946e84
ebe2485
c5145a6
4705449
af913e2
a6b4d06
e4f0b24
c4baaaa
87547f3
8bfa4c8
0202230
3a0a4f1
43d6f8b
7bd3fe1
cff3995
7c8bfc1
c3c6516
d57bf1c
1137ce1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,6 +3,7 @@ | |||||
### Features | ||||||
|
||||||
- `[@jest/environment, jest-runtime]` Allow passing a generic type argument to `jest.createMockFromModule<T>()` method ([#13202](https://github.com/facebook/jest/pull/13202)) | ||||||
- `[jest-circus, jest-cli, jest-config, @jest/core, @jest/types, @jest-util]` Add cli feature to randomize order or tests ([#12922](https://github.com/facebook/jest/pull/12922)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
### Fixes | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -28,6 +28,18 @@ Run tests related to changed files based on hg/git (uncommitted files): | |||||
jest -o | ||||||
``` | ||||||
|
||||||
Run tests in a file in a random order (this will print the seed used for random number generation): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get the idea, but what if this would be moved to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've copied what I've written here to be part of the CLI description of the Was this what you were looking for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. I was trying to say that this usage information could be more useful, if placed next to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh gotcha. Yeah that makes sense. |
||||||
|
||||||
```bash | ||||||
jest --randomize | ||||||
``` | ||||||
|
||||||
Run tests in a file in an order determined by a seed: | ||||||
|
||||||
```bash | ||||||
jest --randomize --seed 1234 | ||||||
``` | ||||||
|
||||||
Run tests related to `path/to/fileA.js` and `path/to/fileB.js`: | ||||||
|
||||||
```bash | ||||||
|
@@ -311,6 +323,11 @@ Allows the test suite to pass when no files are found. | |||||
|
||||||
Run tests from one or more projects, found in the specified paths; also takes path globs. This option is the CLI equivalent of the [`projects`](configuration#projects-arraystring--projectconfig) configuration option. Note that if configuration files are found in the specified paths, _all_ projects specified within those configuration files will be run. | ||||||
|
||||||
### `--randomize` | ||||||
|
||||||
Shuffle the order of the tests within a file. The seed used to generate the new order will be printed to stdout. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add something along the lines of "passing the same |
||||||
In order to determine the seed refer to the `--seed` CLI option. | ||||||
jhwang98 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
### `--reporters` | ||||||
|
||||||
Run tests with specified reporters. [Reporter options](configuration#reporters-arraymodulename--modulename-options) are not available via CLI. Example with multiple reporters: | ||||||
|
@@ -343,6 +360,10 @@ The default regex matching works fine on small runs, but becomes slow if provide | |||||
|
||||||
::: | ||||||
|
||||||
### `--seed` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
might need to tweak the anchor in |
||||||
|
||||||
Run the tests in the order specified by the seed value. Must be used with the `--randomize` flag. | ||||||
jhwang98 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
### `--selectProjects <project1> ... <projectN>` | ||||||
|
||||||
Run the tests of the specified projects. Jest uses the attribute `displayName` in the configuration to identify each project. If you use this option, you should provide a `displayName` to all your projects. | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,344 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`works with each 1`] = ` | ||
"PASS __tests__/each.test.js | ||
✓ test1 | ||
✓ test2 | ||
✓ test3 | ||
describe1 | ||
✓ test4 | ||
✓ test6 | ||
✓ test5 | ||
describe3 | ||
✓ test11 | ||
✓ test12 | ||
✓ test10 | ||
describe4 | ||
✓ test14 | ||
✓ test13 | ||
✓ test15 | ||
describe2 | ||
✓ test4 | ||
✓ test5 | ||
✓ test6" | ||
`; | ||
|
||
exports[`works with hooks 1`] = ` | ||
"Seed is 123 | ||
console.log | ||
This is before all | ||
|
||
at Object.log (__tests__/hooks.test.js:2:11) | ||
|
||
console.log | ||
This is before each | ||
|
||
at Object.log (__tests__/hooks.test.js:6:11) | ||
|
||
console.log | ||
test4 | ||
|
||
at Object.log (__tests__/hooks.test.js:31:13) | ||
|
||
console.log | ||
This is after each | ||
|
||
at Object.log (__tests__/hooks.test.js:10:11) | ||
|
||
console.log | ||
This is before each | ||
|
||
at Object.log (__tests__/hooks.test.js:6:11) | ||
|
||
console.log | ||
test6 | ||
|
||
at Object.log (__tests__/hooks.test.js:39:13) | ||
|
||
console.log | ||
This is after each | ||
|
||
at Object.log (__tests__/hooks.test.js:10:11) | ||
|
||
console.log | ||
This is before each | ||
|
||
at Object.log (__tests__/hooks.test.js:6:11) | ||
|
||
console.log | ||
test5 | ||
|
||
at Object.log (__tests__/hooks.test.js:35:13) | ||
|
||
console.log | ||
This is after each | ||
|
||
at Object.log (__tests__/hooks.test.js:10:11) | ||
|
||
console.log | ||
This is before each | ||
|
||
at Object.log (__tests__/hooks.test.js:6:11) | ||
|
||
console.log | ||
test1 | ||
|
||
at Object.log (__tests__/hooks.test.js:18:11) | ||
|
||
console.log | ||
This is after each | ||
|
||
at Object.log (__tests__/hooks.test.js:10:11) | ||
|
||
console.log | ||
This is before each | ||
|
||
at Object.log (__tests__/hooks.test.js:6:11) | ||
|
||
console.log | ||
This is before each describe3 | ||
|
||
at Object.log (__tests__/hooks.test.js:63:13) | ||
|
||
console.log | ||
test11 | ||
|
||
at Object.log (__tests__/hooks.test.js:71:13) | ||
|
||
console.log | ||
This is after each | ||
|
||
at Object.log (__tests__/hooks.test.js:10:11) | ||
|
||
console.log | ||
This is before each | ||
|
||
at Object.log (__tests__/hooks.test.js:6:11) | ||
|
||
console.log | ||
This is before each describe3 | ||
|
||
at Object.log (__tests__/hooks.test.js:63:13) | ||
|
||
console.log | ||
test12 | ||
|
||
at Object.log (__tests__/hooks.test.js:75:13) | ||
|
||
console.log | ||
This is after each | ||
|
||
at Object.log (__tests__/hooks.test.js:10:11) | ||
|
||
console.log | ||
This is before each | ||
|
||
at Object.log (__tests__/hooks.test.js:6:11) | ||
|
||
console.log | ||
This is before each describe3 | ||
|
||
at Object.log (__tests__/hooks.test.js:63:13) | ||
|
||
console.log | ||
test14 | ||
|
||
at Object.log (__tests__/hooks.test.js:84:15) | ||
|
||
console.log | ||
This is after each | ||
|
||
at Object.log (__tests__/hooks.test.js:10:11) | ||
|
||
console.log | ||
This is before each | ||
|
||
at Object.log (__tests__/hooks.test.js:6:11) | ||
|
||
console.log | ||
This is before each describe3 | ||
|
||
at Object.log (__tests__/hooks.test.js:63:13) | ||
|
||
console.log | ||
test13 | ||
|
||
at Object.log (__tests__/hooks.test.js:80:15) | ||
|
||
console.log | ||
This is after each | ||
|
||
at Object.log (__tests__/hooks.test.js:10:11) | ||
|
||
console.log | ||
This is before each | ||
|
||
at Object.log (__tests__/hooks.test.js:6:11) | ||
|
||
console.log | ||
This is before each describe3 | ||
|
||
at Object.log (__tests__/hooks.test.js:63:13) | ||
|
||
console.log | ||
test15 | ||
|
||
at Object.log (__tests__/hooks.test.js:88:15) | ||
|
||
console.log | ||
This is after each | ||
|
||
at Object.log (__tests__/hooks.test.js:10:11) | ||
|
||
console.log | ||
This is before each | ||
|
||
at Object.log (__tests__/hooks.test.js:6:11) | ||
|
||
console.log | ||
This is before each describe3 | ||
|
||
at Object.log (__tests__/hooks.test.js:63:13) | ||
|
||
console.log | ||
test10 | ||
|
||
at Object.log (__tests__/hooks.test.js:67:13) | ||
|
||
console.log | ||
This is after each | ||
|
||
at Object.log (__tests__/hooks.test.js:10:11) | ||
|
||
console.log | ||
This is before each | ||
|
||
at Object.log (__tests__/hooks.test.js:6:11) | ||
|
||
console.log | ||
test7 | ||
|
||
at Object.log (__tests__/hooks.test.js:49:13) | ||
|
||
console.log | ||
This is after each | ||
|
||
at Object.log (__tests__/hooks.test.js:10:11) | ||
|
||
console.log | ||
This is before each | ||
|
||
at Object.log (__tests__/hooks.test.js:6:11) | ||
|
||
console.log | ||
test8 | ||
|
||
at Object.log (__tests__/hooks.test.js:53:13) | ||
|
||
console.log | ||
This is after each | ||
|
||
at Object.log (__tests__/hooks.test.js:10:11) | ||
|
||
console.log | ||
This is before each | ||
|
||
at Object.log (__tests__/hooks.test.js:6:11) | ||
|
||
console.log | ||
test9 | ||
|
||
at Object.log (__tests__/hooks.test.js:57:13) | ||
|
||
console.log | ||
This is after each | ||
|
||
at Object.log (__tests__/hooks.test.js:10:11) | ||
|
||
console.log | ||
This is after all describe2 | ||
|
||
at Object.log (__tests__/hooks.test.js:45:13) | ||
|
||
console.log | ||
This is before each | ||
|
||
at Object.log (__tests__/hooks.test.js:6:11) | ||
|
||
console.log | ||
test2 | ||
|
||
at Object.log (__tests__/hooks.test.js:22:11) | ||
|
||
console.log | ||
This is after each | ||
|
||
at Object.log (__tests__/hooks.test.js:10:11) | ||
|
||
console.log | ||
This is before each | ||
|
||
at Object.log (__tests__/hooks.test.js:6:11) | ||
|
||
console.log | ||
test3 | ||
|
||
at Object.log (__tests__/hooks.test.js:26:11) | ||
|
||
console.log | ||
This is after each | ||
|
||
at Object.log (__tests__/hooks.test.js:10:11) | ||
|
||
console.log | ||
This is after all | ||
|
||
at Object.log (__tests__/hooks.test.js:14:11) | ||
" | ||
`; | ||
|
||
exports[`works with passing tests 1`] = ` | ||
"PASS __tests__/success.test.js | ||
✓ test1 | ||
✓ test2 | ||
✓ test3 | ||
describe1 | ||
✓ test4 | ||
✓ test6 | ||
✓ test5 | ||
describe3 | ||
✓ test11 | ||
✓ test12 | ||
✓ test10 | ||
describe4 | ||
✓ test14 | ||
✓ test13 | ||
✓ test15 | ||
describe2 | ||
✓ test7 | ||
✓ test8 | ||
✓ test9" | ||
`; | ||
|
||
exports[`works with snapshots 1`] = ` | ||
"PASS __tests__/snapshots.test.js | ||
✓ test1 | ||
✓ test2 | ||
✓ test3 | ||
describe1 | ||
✓ test4 | ||
✓ test6 | ||
✓ test5 | ||
describe3 | ||
✓ test11 | ||
✓ test12 | ||
✓ test10 | ||
describe4 | ||
✓ test14 | ||
✓ test13 | ||
✓ test15 | ||
describe2 | ||
✓ test4 | ||
✓ test5 | ||
✓ test6" | ||
`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can probably split this up into multiple entries. One for "new arguments
seed
andrandomize
" underchore
and one for circus with the randomizing underfeatures