-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
jest-circus runs children in shuffled order #12922
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
Merged
Merged
Changes from all commits
Commits
Show all changes
92 commits
Select commit
Hold shift + click to select a range
e43ca99
jest-circus runs children in shuffled order
jhwang98 bbb1cf3
added shuffle and pseudorandom number generator
jhwang98 4c1d07c
merged master
Joshua-Hwang 99ac4cd
added cli argv
Joshua-Hwang 882f920
removed unnecessary dependencies
Joshua-Hwang 4df23a9
add console logs about the seed
Joshua-Hwang dc6e64f
More readable Math.pow()
Joshua-Hwang 3d09cfb
Used recommended logging approach
Joshua-Hwang f8860e2
Used recommended logging approach
Joshua-Hwang 0bec19f
added prando rng
Joshua-Hwang 3a1d712
bug where rng was recreated every run
Joshua-Hwang 95590dc
swapped order of logs
Joshua-Hwang 14349bd
added typing for the rng
Joshua-Hwang 549988d
Merge branch 'main' of github.com:facebook/jest into feat-randomise-t…
Joshua-Hwang 4ae8ff2
linting issues fixed
jhwang98 967b32e
unit tests are green
jhwang98 561146c
used snapshots instead
jhwang98 2f95b65
added e2e tests
jhwang98 50bada0
changed valid seeds
jhwang98 b78fdc2
added changelog message
jhwang98 3f33508
improved cli help and added documentation
jhwang98 d84caa1
Merge branch 'main' into feat-randomise-tests
jhwang98 b5c34fe
Update docs/CLI.md
jhwang98 b9c5139
Update docs/CLI.md
jhwang98 1b412b4
skipped jasmine
jhwang98 c45244c
updated cli help and docs for randomize
jhwang98 e1e73a0
merged
jhwang98 2152031
updated documentation order
jhwang98 6bb9449
Update docs/CLI.md
jhwang98 164d6fa
Update docs/CLI.md
jhwang98 79401d1
removed whitespace
jhwang98 b6c4da4
added copyright headers
jhwang98 19cf2b5
modifed snapshots to not rely on the actual lines
jhwang98 ca3a582
Merge branch 'main' into feat-randomise-tests
SimenB 2007d47
move changelog entry
SimenB 9361b80
Merge branch 'facebook:main' into feat-randomise-tests
Joshua-Hwang 4d61ba2
merged master
Joshua-Hwang a087ce6
added documentation for configuration
Joshua-Hwang 7b4bd2b
merged main
Joshua-Hwang b175652
using pure-rand
Joshua-Hwang 54cc38c
updated cli message
Joshua-Hwang 974bc5b
added randomize to config
Joshua-Hwang b4e448f
randomize gets passed to config objects
Joshua-Hwang 816b8e6
lint fix
Joshua-Hwang 4ba33d4
group options returns randomize
Joshua-Hwang 7b40ca5
removed unnecessary messages
Joshua-Hwang ebf01d5
improved docs
Joshua-Hwang 9172451
updated types
Joshua-Hwang 0797346
changed the type of the rng
Joshua-Hwang 9c0ff4e
unit tests green
Joshua-Hwang 604499d
added unit tests for the shuffling of tests
Joshua-Hwang 001d150
e2e tests green
Joshua-Hwang 30b3452
small change to docs
Joshua-Hwang 8661cad
e2e test for the config
Joshua-Hwang 81d526b
tweaked changelog
Joshua-Hwang 825fdd9
linting fix
Joshua-Hwang 7512738
factorised test
Joshua-Hwang 888f565
Merge branch 'main' into feat-randomise-tests
Joshua-Hwang a6f6982
Merge branch 'main' into feat-randomise-tests
Joshua-Hwang 57e9836
linting fix
Joshua-Hwang b844e1b
yarn dedupe
Joshua-Hwang bbc70a1
show seed true for randomize
Joshua-Hwang d4509cb
updated docs about randomize
Joshua-Hwang 6ce659d
e2e tests also test randomize
Joshua-Hwang 7bdad9f
updated error message
Joshua-Hwang 08ed42c
Merge branch 'main' of github.com:facebook/jest into feat-randomise-t…
Joshua-Hwang 5fd2e2a
move shuffleArray to jest-circus
Joshua-Hwang 2bffe52
prettier
SimenB f5b919c
improved randomize docs
Joshua-Hwang 2688290
merged master
Joshua-Hwang ec85fb8
Merge branch 'main' of github.com:facebook/jest into feat-randomise-t…
Joshua-Hwang 94c0740
Merge branch 'main' of github.com:facebook/jest into feat-randomise-t…
Joshua-Hwang e212ed9
Merge branch 'main' into feat-randomise-tests
SimenB 5946e84
lint fix
jhwang98 ebe2485
merged main
jhwang98 c5145a6
Merge branch 'main' of https://github.com/facebook/jest into feat-ran…
jhwang98 4705449
merged main
jhwang98 af913e2
bumped pure-rand package
jhwang98 a6b4d06
Merge branch 'main' into feat-randomise-tests
jhwang98 e4f0b24
Merge branch 'main' into feat-randomise-tests
jhwang98 c4baaaa
yarn.lock updated
jhwang98 87547f3
fixed copyright headers
jhwang98 8bfa4c8
Merge branch 'main' into feat-randomise-tests
Joshua-Hwang 0202230
Merge branch 'main' into feat-randomise-tests
SimenB 3a0a4f1
Update packages/jest-config/src/normalize.ts
jhwang98 43d6f8b
Update packages/jest-core/src/cli/index.ts
jhwang98 7bd3fe1
Update packages/jest-circus/src/shuffleArray.ts
jhwang98 cff3995
remove bounds check as it's being done at the normalize level
jhwang98 7c8bfc1
changed error message slightly
jhwang98 c3c6516
swapped order for generating rng
jhwang98 d57bf1c
Update packages/jest-circus/src/run.ts
SimenB 1137ce1
Update packages/jest-circus/src/run.ts
SimenB File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,89 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`works with each 1`] = ` | ||
| " ✓ test1 | ||
| ✓ test2 | ||
| ✓ test3 | ||
| describe2 | ||
| ✓ test4 | ||
| ✓ test6 | ||
| ✓ test5 | ||
| describe1 | ||
| ✓ test4 | ||
| ✓ test6 | ||
| ✓ test5 | ||
| describe3 | ||
| ✓ test11 | ||
| ✓ test12 | ||
| ✓ test10 | ||
| describe4 | ||
| ✓ test14 | ||
| ✓ test15 | ||
| ✓ test13" | ||
| `; | ||
|
|
||
| exports[`works with hooks 1`] = ` | ||
| " ✓ test1 | ||
| ✓ test2 | ||
| ✓ test3 | ||
| describe2 | ||
| ✓ test7 | ||
| ✓ test9 | ||
| ✓ test8 | ||
| describe1 | ||
| ✓ test4 | ||
| ✓ test6 | ||
| ✓ test5 | ||
| describe3 | ||
| ✓ test11 | ||
| ✓ test12 | ||
| ✓ test10 | ||
| describe4 | ||
| ✓ test14 | ||
| ✓ test15 | ||
| ✓ test13" | ||
| `; | ||
|
|
||
| exports[`works with passing tests 1`] = ` | ||
| " ✓ test1 | ||
| ✓ test2 | ||
| ✓ test3 | ||
| describe2 | ||
| ✓ test7 | ||
| ✓ test9 | ||
| ✓ test8 | ||
| describe1 | ||
| ✓ test4 | ||
| ✓ test6 | ||
| ✓ test5 | ||
| describe3 | ||
| ✓ test11 | ||
| ✓ test12 | ||
| ✓ test10 | ||
| describe4 | ||
| ✓ test14 | ||
| ✓ test15 | ||
| ✓ test13" | ||
| `; | ||
|
|
||
| exports[`works with snapshots 1`] = ` | ||
| " ✓ test1 | ||
| ✓ test2 | ||
| ✓ test3 | ||
| describe2 | ||
| ✓ test4 | ||
| ✓ test6 | ||
| ✓ test5 | ||
| describe1 | ||
| ✓ test4 | ||
| ✓ test6 | ||
| ✓ test5 | ||
| describe3 | ||
| ✓ test11 | ||
| ✓ test12 | ||
| ✓ test10 | ||
| describe4 | ||
| ✓ test14 | ||
| ✓ test15 | ||
| ✓ test13" | ||
| `; |
This file contains hidden or 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,85 @@ | ||
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| import * as path from 'path'; | ||
| import {skipSuiteOnJasmine} from '@jest/test-utils'; | ||
| import {extractSummary} from '../Utils'; | ||
| import runJest, {RunJestResult} from '../runJest'; | ||
|
|
||
| skipSuiteOnJasmine(); | ||
|
|
||
| const dir = path.resolve(__dirname, '../randomize'); | ||
|
|
||
| const trimFirstLine = (str: string): string => | ||
| str.split('\n').slice(1).join('\n'); | ||
|
|
||
| function runJestTwice( | ||
| dir: string, | ||
| args: Array<string>, | ||
| ): [RunJestResult, RunJestResult] { | ||
| return [ | ||
| runJest(dir, [...args, '--randomize']), | ||
| runJest(dir, [...args, '--config', 'different-config.json']), | ||
| ]; | ||
| } | ||
|
|
||
| test('works with passing tests', () => { | ||
| const [result1, result2] = runJestTwice(dir, [ | ||
| 'success.test.js', | ||
| '--seed', | ||
| '123', | ||
| ]); | ||
|
|
||
| const rest1 = trimFirstLine(extractSummary(result1.stderr).rest); | ||
| const rest2 = trimFirstLine(extractSummary(result2.stderr).rest); | ||
|
|
||
| expect(rest1).toEqual(rest2); | ||
| expect(rest1).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test('works with each', () => { | ||
| const [result1, result2] = runJestTwice(dir, [ | ||
| 'each.test.js', | ||
| '--seed', | ||
| '123', | ||
| ]); | ||
|
|
||
| const rest1 = trimFirstLine(extractSummary(result1.stderr).rest); | ||
| const rest2 = trimFirstLine(extractSummary(result2.stderr).rest); | ||
|
|
||
| expect(rest1).toEqual(rest2); | ||
| expect(rest1).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test('works with hooks', () => { | ||
| const [result1, result2] = runJestTwice(dir, [ | ||
| 'hooks.test.js', | ||
| '--seed', | ||
| '123', | ||
| ]); | ||
|
|
||
| // Change in formatting could change this one | ||
| const rest1 = trimFirstLine(extractSummary(result1.stderr).rest); | ||
| const rest2 = trimFirstLine(extractSummary(result2.stderr).rest); | ||
|
|
||
| expect(rest1).toEqual(rest2); | ||
| expect(rest1).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test('works with snapshots', () => { | ||
| const [result1, result2] = runJestTwice(dir, [ | ||
| 'snapshots.test.js', | ||
| '--seed', | ||
| '123', | ||
| ]); | ||
|
|
||
| const rest1 = trimFirstLine(extractSummary(result1.stderr).rest); | ||
| const rest2 = trimFirstLine(extractSummary(result2.stderr).rest); | ||
|
|
||
| expect(rest1).toEqual(rest2); | ||
| expect(rest1).toMatchSnapshot(); | ||
| }); | ||
This file contains hidden or 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 hidden or 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,4 @@ | ||
| { | ||
| "displayName": "Config from randomize-config.json file", | ||
| "randomize": true | ||
| } |
This file contains hidden or 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,4 @@ | ||
| { | ||
| "displayName": "Config from showSeed-config.json file", | ||
| "showSeed": true | ||
| } |
31 changes: 31 additions & 0 deletions
31
e2e/randomize/__tests__/__snapshots__/snapshots.test.js.snap
This file contains hidden or 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,31 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`describe1 test4 1`] = `4`; | ||
|
|
||
| exports[`describe1 test5 1`] = `5`; | ||
|
|
||
| exports[`describe1 test6 1`] = `6`; | ||
|
|
||
| exports[`describe2 test4 1`] = `4`; | ||
|
|
||
| exports[`describe2 test5 1`] = `5`; | ||
|
|
||
| exports[`describe2 test6 1`] = `6`; | ||
|
|
||
| exports[`describe3 describe4 test13 1`] = `13`; | ||
|
|
||
| exports[`describe3 describe4 test14 1`] = `14`; | ||
|
|
||
| exports[`describe3 describe4 test15 1`] = `15`; | ||
|
|
||
| exports[`describe3 test10 1`] = `10`; | ||
|
|
||
| exports[`describe3 test11 1`] = `11`; | ||
|
|
||
| exports[`describe3 test12 1`] = `12`; | ||
|
|
||
| exports[`test1 1`] = `1`; | ||
|
|
||
| exports[`test2 1`] = `2`; | ||
|
|
||
| exports[`test3 1`] = `3`; |
This file contains hidden or 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 @@ | ||
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| it.each([1, 2, 3])('test%d', () => { | ||
| expect(true).toBe(true); | ||
| }); | ||
|
|
||
| describe.each([1, 2])('describe%d', () => { | ||
| it.each([4, 5, 6])('test%d', () => { | ||
| expect(true).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe('describe3', () => { | ||
| it.each([10, 11, 12])('test%d', () => { | ||
| expect(true).toBe(true); | ||
| }); | ||
|
|
||
| describe('describe4', () => { | ||
| it.each([13, 14, 15])('test%d', () => { | ||
| expect(true).toBe(true); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.