Skip to content

Commit 657ac46

Browse files
ci(repo): hash files chrome-extension tests import from clerk-js
no-rhc.test.ts imports createBaseEnvironmentJSON from packages/clerk-js/src/test/fixtures.ts, which neither the suite inputs nor the clerk-js build hashed, so editing it reused a stale result. The dependency check now fails when a scoped suite's tests import a runtime file from outside integration/ that its inputs don't list.
1 parent 393d3f3 commit 657ac46

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

‎integration/presets/__tests__/suiteBuildDependencies.test.ts‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
2-
import { dirname, join, resolve, sep } from 'node:path';
2+
import { dirname, join, relative, resolve, sep } from 'node:path';
33

44
import { beforeAll, describe, expect, it, vi } from 'vitest';
55

@@ -31,8 +31,12 @@ const harnessPackages = Object.entries<string>(rootPackage.devDependencies)
3131
.map(([name]) => name);
3232

3333
const scopedSuites = Object.entries<{ dependsOn?: string[]; inputs: string[] }>(turbo.tasks)
34-
.filter(([id, task]) => id.startsWith('//#test:integration:') && !task.inputs.some(i => i.startsWith('packages/')))
35-
.map(([id, task]) => ({ suite: id.replace('//#test:integration:', ''), dependsOn: task.dependsOn ?? [] }));
34+
.filter(([id, task]) => id.startsWith('//#test:integration:') && !task.inputs.includes('packages/*/src/**'))
35+
.map(([id, task]) => ({
36+
suite: id.replace('//#test:integration:', ''),
37+
dependsOn: task.dependsOn ?? [],
38+
inputs: task.inputs,
39+
}));
3640

3741
const helperDirs = [testsDir, resolve(repoRoot, 'integration/testUtils')];
3842

@@ -97,6 +101,14 @@ const suiteFiles = (suite: string) => {
97101
return [];
98102
};
99103

104+
const importsOutsideIntegration = (suite: string) =>
105+
suiteFiles(suite).flatMap(file =>
106+
[...readFileSync(file, 'utf8').matchAll(/^import (?!type )[^;]*?from '(\.{1,2}\/[^']+)'/gm)]
107+
.map(([, specifier]) => resolveImport(file, specifier))
108+
.filter((target): target is string => !!target && !target.startsWith(resolve(repoRoot, 'integration') + sep))
109+
.map(target => relative(repoRoot, target)),
110+
);
111+
100112
let appConfigs: typeof AppConfigs;
101113

102114
beforeAll(async () => {
@@ -154,7 +166,7 @@ describe('scoped integration suites declare the builds they load', () => {
154166
expect(harnessPackages).toEqual(expect.arrayContaining(['@clerk/backend', '@clerk/shared', '@clerk/testing']));
155167
});
156168

157-
describe.each(scopedSuites)('$suite', ({ suite, dependsOn }) => {
169+
describe.each(scopedSuites)('$suite', ({ suite, dependsOn, inputs }) => {
158170
it('selects its tests with a --grep tag or its own config, and its apps by id or from its tests', () => {
159171
const { script, tag, ownConfig } = parseScript(suite);
160172
expect(script, `package.json has no test:integration:${suite} script`).toBeDefined();
@@ -174,5 +186,9 @@ describe('scoped integration suites declare the builds they load', () => {
174186
.sort();
175187
expect([...dependsOn].sort()).toEqual(expected);
176188
});
189+
190+
it('hashes the files its tests import from outside integration/', () => {
191+
expect(inputs).toEqual(expect.arrayContaining(importsOutsideIntegration(suite)));
192+
});
177193
});
178194
});

‎turbo.json‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,12 @@
934934
"REACT_APP_CLERK_*",
935935
"VITE_CLERK_*"
936936
],
937-
"inputs": ["integration/**", "!integration/playwright-report/**", "!integration/test-results/**"],
937+
"inputs": [
938+
"integration/**",
939+
"packages/clerk-js/src/test/fixtures.ts",
940+
"!integration/playwright-report/**",
941+
"!integration/test-results/**"
942+
],
938943
"outputs": ["integration/playwright-report/**"],
939944
"outputLogs": "new-only"
940945
},

0 commit comments

Comments
 (0)