[engine] PurityLint: Load ESLint once in beforeAll so a cold start under load cannot time out the first case

This commit is contained in:
2026-11-01 21:31:34 +01:00
parent 23e950c372
commit e0cbfc466a
3 changed files with 23 additions and 2 deletions
+7 -1
View File
@@ -8,7 +8,7 @@
*/
import { ESLint } from 'eslint';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'vitest';
import { beforeAll, describe, expect, it } from 'vitest';
const repoRoot = fileURLToPath(new URL('../../..', import.meta.url));
const eslint = new ESLint({ cwd: repoRoot });
@@ -42,6 +42,12 @@ const IMPURE: readonly [what: string, code: string][] = [
];
describe('engine purity lint rule', () => {
// The first lint loads the config and typescript-eslint. On a busy machine that
// alone took over vitest's 5 s, failing whichever case ran first. Pay it here.
beforeAll(async () => {
await messages('export {};', ENGINE_FILE);
}, 60_000);
it.each(IMPURE)('reports %s inside packages/engine/src', async (_what, code) => {
const found = await messages(code, ENGINE_FILE);
expect(found.filter((m) => m.startsWith('fatal')), 'snippet must parse').toEqual([]);