Skip to content

Commit 7f54c2d

Browse files
committed
Add test sequencer
1 parent aa97373 commit 7f54c2d

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

jest-sequencer.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const Sequencer = require('@jest/test-sequencer').default;
2+
3+
class TestSequencer extends Sequencer {
4+
shard(tests, {shardIndex, shardCount}) {
5+
const shardSize = Math.ceil(tests.length / shardCount);
6+
const shardStart = shardSize * (shardIndex - 1);
7+
const shardEnd = shardSize * shardIndex;
8+
9+
return [...tests].sort((a, b) => (a.path > b.path ? 1 : -1)).slice(shardStart, shardEnd);
10+
}
11+
12+
sort(tests) {
13+
const copyTests = [...tests];
14+
return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1));
15+
}
16+
}
17+
18+
module.exports = TestSequencer;

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ module.exports = {
1414
setupFilesAfterEnv: ['./jestSetup.js'],
1515
testTimeout: 60000,
1616
transformIgnorePatterns: ['node_modules/(?!((@)?react-native|@ngneat/falso|uuid)/)'],
17+
testSequencer: './jest-sequencer.js',
1718
};

0 commit comments

Comments
 (0)