Skip to content

Commit a341101

Browse files
authored
make sure we run wrangler e2e tests in nested folders (#10174)
1 parent 4e62cd8 commit a341101

File tree

3 files changed

+75
-12
lines changed

3 files changed

+75
-12
lines changed

pnpm-lock.yaml

Lines changed: 58 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/e2e/runIndividualE2EFiles.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import assert from "assert";
12
import { execSync } from "child_process";
2-
import { readdirSync } from "fs";
3+
import { statSync } from "fs";
4+
import path from "path";
5+
import { globIterateSync } from "glob";
36
import type { ExecSyncOptionsWithBufferEncoding } from "child_process";
47

58
// Turbo only supports caching on the individual task level, but for Wrangler's
@@ -27,19 +30,22 @@ const command =
2730
extraParams.join(" ");
2831

2932
const failed: string[] = [];
30-
for (const file of readdirSync("packages/wrangler/e2e")) {
31-
if (!file.endsWith(".test.ts")) {
32-
// Ignore other files in the e2e directory (the README, for instance)
33-
continue;
34-
}
3533

36-
const WRANGLER_E2E_TEST_FILE = `e2e/${file}`;
34+
const wranglerPath = path.join(__dirname, "../../packages/wrangler");
35+
assert(statSync(wranglerPath).isDirectory());
36+
37+
for (const testFile of globIterateSync("e2e/**/*.test.ts", {
38+
cwd: wranglerPath,
39+
// Return `/` delimited paths, even on Windows.
40+
posix: true,
41+
})) {
3742
const options: ExecSyncOptionsWithBufferEncoding = {
3843
stdio: "inherit",
39-
env: { ...process.env, WRANGLER_E2E_TEST_FILE },
44+
env: { ...process.env, WRANGLER_E2E_TEST_FILE: testFile },
4045
};
4146

42-
console.log("::group::Testing: " + WRANGLER_E2E_TEST_FILE);
47+
console.log(`::group::Testing: ${testFile}`);
48+
4349
try {
4450
execSync(command, options);
4551
} catch {
@@ -48,7 +54,7 @@ for (const file of readdirSync("packages/wrangler/e2e")) {
4854
execSync(command, options);
4955
} catch {
5056
console.error("Still failed, moving on");
51-
failed.push(file);
57+
failed.push(testFile);
5258
}
5359
}
5460
console.log("::endgroup::");

tools/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@typescript-eslint/eslint-plugin": "catalog:default",
1515
"@typescript-eslint/parser": "catalog:default",
1616
"find-up": "^6.3.0",
17+
"glob": "^11.0.3",
1718
"ts-dedent": "^2.2.0",
1819
"undici": "catalog:default",
1920
"wrangler": "workspace:*"

0 commit comments

Comments
 (0)