Skip to content

Commit b36783c

Browse files
test: reduce flakes on pages-dev e2e tests (#10284)
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 dab7683 commit b36783c

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,19 @@ describe.sequential.each([{ cmd: "wrangler pages dev" }])(
118118
`${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`
119119
);
120120
await worker.waitForReady();
121-
expect(normalizeOutput(worker.currentOutput)).toContain(
122-
dedent`Your worker has access to the following bindings:
123-
- Durable Objects:
124-
- TEST_DO: TestDurableObject (defined in a [not connected])
125-
- KV Namespaces:
126-
- TEST_KV: TEST_KV [simulated locally]
127-
- D1 Databases:
128-
- TEST_D1: local-TEST_D1 (TEST_D1) [simulated locally]
129-
- R2 Buckets:
130-
- TEST_R2: TEST_R2 [simulated locally]
131-
- Services:
132-
- TEST_SERVICE: test-worker [not connected]
133-
`
121+
const bindingMessages = worker.currentOutput.split(
122+
"Your worker has access to the following bindings:"
134123
);
124+
const bindings = Array.from(
125+
(bindingMessages[1] ?? "").matchAll(/ {2}- [A-Z_0-9]+:[^\n]+/g)
126+
).flat();
127+
expect(bindings).toEqual([
128+
" - TEST_DO: TestDurableObject (defined in a [not connected])",
129+
" - TEST_KV: TEST_KV [simulated locally]",
130+
" - TEST_D1: local-TEST_D1 (TEST_D1) [simulated locally]",
131+
" - TEST_R2: TEST_R2 [simulated locally]",
132+
" - TEST_SERVICE: test-worker [not connected]",
133+
]);
135134
});
136135

137136
it("should support wrangler.toml", async () => {

0 commit comments

Comments
 (0)