Commit d2d835e1 authored by Albert Salim's avatar Albert Salim

Enable parallel jest

parent 58b1f41a
......@@ -207,7 +207,7 @@ karma-as-if-foss:
extends: .frontend-job-base
script:
- date
- yarn jest --ci --coverage
- yarn jest --ci --coverage --testSequencer ./scripts/frontend/parallel_ci_sequencer.js
cache:
key: jest
paths:
......@@ -229,6 +229,7 @@ jest:
- tmp/tests/frontend/
reports:
junit: junit_jest.xml
parallel: 2
jest-as-if-foss:
extends:
......
const Sequencer = require('@jest/test-sequencer').default;
class ParallelCISequencer extends Sequencer {
constructor() {
super();
this.ciNodeIndex = parseInt(process.env.CI_NODE_INDEX || '1');
this.ciNodeTotal = parseInt(process.env.CI_NODE_TOTAL || '1');
}
sort(tests) {
const testsForThisRunner = this.distributeAcrossCINodes(tests);
console.log(`CI_NODE_INDEX: ${this.ciNodeIndex}`);
console.log(`CI_NODE_TOTAL: ${this.ciNodeTotal}`);
console.log(`Total number of tests: ${tests.length}`);
console.log(`Total number of tests for this runner: ${testsForThisRunner.length}`);
return super.sort(testsForThisRunner);
}
distributeAcrossCINodes(tests) {
return tests.filter((test, index) => {
return index % this.ciNodeTotal === this.ciNodeIndex - 1;
});
}
}
module.exports = ParallelCISequencer;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment