From 86ed5b50cb4573a1af0dde4333299cbf01c2674d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=8E?= Date: Fri, 27 Oct 2023 20:25:04 +0800 Subject: [PATCH] fix(runner): sort test imports to make the output stable --- src/server/Runner.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/server/Runner.ts b/src/server/Runner.ts index 47dc6f3..d107dac 100644 --- a/src/server/Runner.ts +++ b/src/server/Runner.ts @@ -256,8 +256,13 @@ export default class Runner implements Disposable { setup: (pluginBuild) => { pluginBuild.onResolve({ filter: /^$/ }, () => ({ path: 'stdin', namespace: 'wrightplay' })); pluginBuild.onLoad({ filter: /^/, namespace: 'wrightplay' }, async () => { + // Sort to make the output stable const importFiles = await testFinder.getFiles(); + importFiles.sort(); + + // Prepend the setup file if any if (setupFile) importFiles.unshift(setupFile.replace(/\\/g, '\\\\')); + if (importFiles.length === 0) { if (watch) { // eslint-disable-next-line no-console @@ -266,6 +271,7 @@ export default class Runner implements Disposable { throw new Error('No test file found'); } } + const importStatements = importFiles.map((file) => `import '${file}'`).join('\n'); return { contents: `${importStatements}\n(${clientRunner.init.toString()})('${this.uuid}')`,