forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support async sort in custom testSequencer. (jestjs#8642)
* Support async sort in testSequencer. * Add e2e test for async testSequencer. * Update CHANGELOG.md * Update CHANGELOG.md
- Loading branch information
1 parent
bb01c94
commit 9c70ba0
Showing
6 changed files
with
65 additions
and
7 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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
{ | ||
"jest": { | ||
"testEnvironment": "node", | ||
"testSequencer": "<rootDir>/testSequencer.js" | ||
"testEnvironment": "node" | ||
} | ||
} |
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,23 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* 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 { | ||
sort(tests) { | ||
return new Promise(resolve => { | ||
setTimeout(() => { | ||
const copyTests = Array.from(tests); | ||
resolve( | ||
copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)) | ||
); | ||
}, 50); | ||
}); | ||
} | ||
} | ||
|
||
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