From 48156aee06bd4ff63cb302ea69f58699eee72efc Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Mon, 14 Oct 2024 09:40:22 -0400 Subject: [PATCH] test: run visibility-state-spec.ts first (#44206) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> --- script/split-tests.js | 9 --------- spec/index.js | 12 +++++++++++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/script/split-tests.js b/script/split-tests.js index b31c0934d9f9..51c0ad7f674b 100644 --- a/script/split-tests.js +++ b/script/split-tests.js @@ -3,8 +3,6 @@ const glob = require('glob'); const fs = require('node:fs'); const path = require('node:path'); -const VISIBILITY_SPEC = 'spec\\visibility-state-spec.ts'; - const currentShard = parseInt(process.argv[2], 10); const shardCount = parseInt(process.argv[3], 10); @@ -33,11 +31,4 @@ for (const specFile of specFiles) { if (shard === shardCount) shard = 0; } -const visiblitySpecIdx = buckets[currentShard - 1]; -if (visiblitySpecIdx > -1) { - // If visibility-state-spec is in the list, move it to the first position - // so that it gets executed first to avoid other specs interferring with it. - buckets[currentShard - 1].splice(visiblitySpecIdx, 1); - buckets[currentShard - 1].unshift(VISIBILITY_SPEC); -} console.log(buckets[currentShard - 1].join(' ')); diff --git a/spec/index.js b/spec/index.js index fe5ef6abf18a..344b00615682 100644 --- a/spec/index.js +++ b/spec/index.js @@ -149,7 +149,17 @@ app.whenReady().then(async () => { const { getFiles } = require('./get-files'); const testFiles = await getFiles(__dirname, filter); - for (const file of testFiles.sort()) { + const VISIBILITY_SPEC = ('visibility-state-spec.ts'); + const sortedFiles = testFiles.sort((a, b) => { + // If visibility-state-spec is in the list, move it to the first position + // so that it gets executed first to avoid other specs interferring with it. + if (a.indexOf(VISIBILITY_SPEC) > -1) { + return -1; + } else { + return a.localeCompare(b); + } + }); + for (const file of sortedFiles) { mocha.addFile(file); }