Skip to content

Commit 026b485

Browse files
test: reduce flakes on pages-dev e2e tests (#10280)
Occasionally this test flaked because the dev process output the bindings twice. I believe this is a timings issue around watching for file changes, triggering a second update and printing of the bindings So now we only extract the first bindings list and clean it up to make it resilient to flaking
1 parent 80960b9 commit 026b485

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

packages/wrangler/e2e/pages-dev.test.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,20 @@ describe.sequential("wrangler pages dev", () => {
117117
`${cmd} --inspector-port ${inspectorPort} . --port ${port} --service TEST_SERVICE=test-worker --kv TEST_KV --do TEST_DO=TestDurableObject@a --d1 TEST_D1 --r2 TEST_R2 --compatibility-date=2025-05-21`
118118
);
119119
await worker.waitForReady();
120-
expect(normalizeOutput(worker.currentOutput)).toMatchInlineSnapshot(`
121-
"✨ Compiled Worker successfully
122-
Your Worker has access to the following bindings:
123-
Binding Resource Mode
124-
env.TEST_DO (TestDurableObject, defined in a) Durable Object local [not connected]
125-
env.TEST_KV (TEST_KV) KV Namespace local
126-
env.TEST_D1 (local-TEST_D1) D1 Database local
127-
env.TEST_R2 (TEST_R2) R2 Bucket local
128-
env.TEST_SERVICE (test-worker) Worker local [not connected]
129-
Service bindings, Durable Object bindings, and Tail consumers connect to other \`wrangler dev\` processes running locally, with their connection status indicated by [connected] or [not connected]. For more details, refer to https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/#local-development
130-
⎔ Starting local server...
131-
[wrangler:info] Ready on http://<HOST>:<PORT>"
120+
const bindingMessages = worker.currentOutput.split(
121+
"Your Worker has access to the following bindings:"
122+
);
123+
const bindings = Array.from(
124+
(bindingMessages[1] ?? "").matchAll(/env\.[^\n]+/g)
125+
).flat();
126+
expect(bindings).toMatchInlineSnapshot(`
127+
[
128+
"env.TEST_DO (TestDurableObject, defined in a) Durable Object local [not connected]",
129+
"env.TEST_KV (TEST_KV) KV Namespace local",
130+
"env.TEST_D1 (local-TEST_D1) D1 Database local",
131+
"env.TEST_R2 (TEST_R2) R2 Bucket local",
132+
"env.TEST_SERVICE (test-worker) Worker local [not connected]",
133+
]
132134
`);
133135
});
134136

0 commit comments

Comments
 (0)