-
-
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.
Exposes globalConfig to custom test sequencers (#14535)
- Loading branch information
1 parent
0a45938
commit 76a47d8
Showing
5 changed files
with
95 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
const Sequencer = require('@jest/test-sequencer').default; | ||
|
||
class CustomSequencer extends Sequencer { | ||
constructor(_options) { | ||
super(_options); | ||
this.globalConfig = _options.globalConfig; | ||
} | ||
|
||
sort(tests) { | ||
const copyTests = Array.from(tests); | ||
const seed = this.globalConfig.seed; | ||
const sortedTests = copyTests.sort((testA, testB) => | ||
testA.path > testB.path ? 1 : -1, | ||
); | ||
|
||
if (seed % 2 === 0) { | ||
return sortedTests; | ||
} else { | ||
return sortedTests.reverse(); | ||
} | ||
} | ||
} | ||
|
||
module.exports = CustomSequencer; |
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