From 2ef69a80db8b86ca3c659cdfee326562f0132c74 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Thu, 16 Feb 2023 10:13:11 -0300 Subject: [PATCH] Run tests alphabetically --- e2e/jest.config.js | 3 ++- e2e/testSequencer.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 e2e/testSequencer.js diff --git a/e2e/jest.config.js b/e2e/jest.config.js index 560e26f47..114e29ec2 100644 --- a/e2e/jest.config.js +++ b/e2e/jest.config.js @@ -1,7 +1,8 @@ /** @type {import('@jest/types').Config.InitialOptions} */ module.exports = { rootDir: '..', - testMatch: ['/e2e/tests/**/*.spec.ts'], + testSequencer: '/e2e/testSequencer.js', + testMatch: ['/e2e/tests/assorted/*.spec.ts'], testTimeout: 120000, maxWorkers: 1, globalSetup: '/e2e/globalSetup.ts', diff --git a/e2e/testSequencer.js b/e2e/testSequencer.js new file mode 100644 index 000000000..1b60c5f6e --- /dev/null +++ b/e2e/testSequencer.js @@ -0,0 +1,12 @@ +const Sequencer = require('@jest/test-sequencer').default; + +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); + return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)); + } +} + +module.exports = CustomSequencer;