forked from imjuni/ctix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.spec.js
29 lines (24 loc) · 838 Bytes
/
test.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const Sequencer = require('@jest/test-sequencer').default;
const path = require('path');
const testWeight = {
'config.test.ts': 0,
'file.test.ts': 1,
'tsfile.test.ts': 2,
'write.test.ts': 3,
'clean.test.ts': 4,
};
class CustomSequencer extends Sequencer {
sort(tests) {
// Test structure information
// https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21
const copyTests = Array.from(tests);
const testSize = copyTests.length;
const sorted = copyTests.sort((left, right) => {
const leftWeight = testSize - testWeight[path.basename(left.path)];
const rightWeight = testSize - testWeight[path.basename(right.path)];
return rightWeight - leftWeight;
});
return sorted;
}
}
module.exports = CustomSequencer;