Skip to content

Commit 25cb184

Browse files
[wrangler] fix e2e flakiness: use waitForLong to verify response body after deploy (#13057)
1 parent 6b50bfa commit 25cb184

3 files changed

Lines changed: 38 additions & 24 deletions

File tree

packages/wrangler/e2e/assets-multiworker.test.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,21 @@ describe.each(
211211
false
212212
);
213213

214-
await expect(fetchText(`${url}/asset`)).resolves.toBe(
215-
"<p>have an asset directly</p>"
214+
await waitForLong(() =>
215+
expect(fetchText(`${url}/asset`)).resolves.toBe(
216+
"<p>have an asset directly</p>"
217+
)
216218
);
217-
await expect(fetchText(`${url}/asset-via-binding`)).resolves.toBe(
218-
"<p>have an asset via a binding</p>"
219+
await waitForLong(() =>
220+
expect(fetchText(`${url}/asset-via-binding`)).resolves.toBe(
221+
"<p>have an asset via a binding</p>"
222+
)
223+
);
224+
await waitForLong(() =>
225+
expect(fetch(`${url}/worker`).then((r) => r.text())).resolves.toBe(
226+
"hello world from a worker with assets"
227+
)
219228
);
220-
await expect(
221-
fetch(`${url}/worker`).then((r) => r.text())
222-
).resolves.toBe("hello world from a worker with assets");
223229
});
224230

225231
it("can fetch a regular worker through a worker with assets, including with rpc", async ({

packages/wrangler/e2e/deployments.test.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
6363

6464
const deployedUrl = getDeployedUrl(output);
6565

66-
const response = await retry(
67-
(resp) => !resp.ok,
68-
async () => await fetch(deployedUrl)
66+
await waitForLong(
67+
async () => {
68+
const response = await fetch(deployedUrl);
69+
expect(await response.text()).toEqual("Hello World!");
70+
},
71+
{ timeout: 30_000 }
6972
);
70-
await expect(response.text()).resolves.toEqual("Hello World!");
7173
});
7274

7375
it("lists 1 deployment", async ({ expect }) => {
@@ -98,11 +100,13 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
98100

99101
const deployedUrl = getDeployedUrl(output);
100102

101-
const response = await retry(
102-
(resp) => !resp.ok,
103-
async () => await fetch(deployedUrl)
103+
await waitForLong(
104+
async () => {
105+
const response = await fetch(deployedUrl);
106+
expect(await response.text()).toEqual("Updated Worker!");
107+
},
108+
{ timeout: 30_000 }
104109
);
105-
await expect(response.text()).resolves.toEqual("Updated Worker!");
106110
});
107111

108112
it("lists 2 deployments", async ({ expect }) => {

packages/wrangler/e2e/provision.test.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { WranglerE2ETestHelper } from "./helpers/e2e-wrangler-test";
66
import { fetchText } from "./helpers/fetch-text";
77
import { generateResourceName } from "./helpers/generate-resource-name";
88
import { normalizeOutput } from "./helpers/normalize";
9-
import { retry } from "./helpers/retry";
9+
import { waitForLong } from "./helpers/wait-for";
1010

1111
const TIMEOUT = 500_000;
1212
const normalize = (str: string) => {
@@ -122,11 +122,13 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
122122
assert(d1Match?.groups);
123123
d1Id = d1Match.groups.d1;
124124

125-
const response = await retry(
126-
(resp) => !resp.ok,
127-
async () => await fetch(deployedUrl)
125+
await waitForLong(
126+
async () => {
127+
const response = await fetch(deployedUrl);
128+
expect(await response.text()).toEqual("Hello World!");
129+
},
130+
{ timeout: 30_000 }
128131
);
129-
await expect(response.text()).resolves.toEqual("Hello World!");
130132
});
131133

132134
it("can inherit bindings on re-deploy and won't re-provision", async ({
@@ -149,11 +151,13 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
149151
Current Version ID: 00000000-0000-0000-0000-000000000000"
150152
`);
151153

152-
const response = await retry(
153-
(resp) => !resp.ok,
154-
async () => await fetch(deployedUrl)
154+
await waitForLong(
155+
async () => {
156+
const response = await fetch(deployedUrl);
157+
expect(await response.text()).toEqual("Hello World!");
158+
},
159+
{ timeout: 30_000 }
155160
);
156-
await expect(response.text()).resolves.toEqual("Hello World!");
157161
});
158162
it("can inspect current bindings", async ({ expect }) => {
159163
const versionsRaw = await helper.run(`wrangler versions list --json`);

0 commit comments

Comments
 (0)