-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jest-circus runs children in shuffled order (#12922)
- Loading branch information
Showing
33 changed files
with
889 additions
and
35 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
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,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 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 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,4 @@ | ||
{ | ||
"displayName": "Config from randomize-config.json file", | ||
"randomize": true | ||
} |
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,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 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 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.