Skip to content

Commit 0ff1964

Browse files
Fix vitest-pool-workers when nodejs_compat is enabled (#11047)
* chore: remove deprecated workspace config from vitest-pool-workers fixture * allow vitest-pool-workers to infer the latest compatibility date if none is provided * update vitest-pool-workers tests to use the latest compatibility date * fix missing await on async expectation in vitest-pool-workers fixture * add nodejs test to vitest-pool-workers fixture * ensure that vitest specific nodejs polyfills override native modules * url polyfill is not needed * remove unnecessary polyfills from Vitest pool workers, ensuring that the necessary native features are enabled * rework helper to make its purpose more clear * revert simplification of console polyfill * move timeout options param as the current location is deprecated * add an extra debugging log in when the devregistry fails to dispose * Bump up the hook timeout on vitest-pool-workers tests Occasionally I saw this failing during the global setup * ensure chunking test has a big enough max buffer * escalate the signal if a vitest-pool-workers test fails because it is killed
1 parent af18b48 commit 0ff1964

File tree

60 files changed

+162
-291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+162
-291
lines changed

.changeset/gold-paws-serve.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/vitest-pool-workers": minor
3+
---
4+
5+
Infer latest locally available compatibility date if none is provided in the test configuration

.changeset/true-groups-end.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/vitest-pool-workers": patch
3+
---
4+
5+
ensure that vitest specific nodejs polyfills override native modules

fixtures/vitest-pool-workers-examples/ai-vectorize/wrangler.jsonc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "ai-vectorize",
33
"main": "src/index.ts",
4+
// compatibility_date is required so we can run `wrangler build`
45
"compatibility_date": "2025-03-20",
56
"ai": {
67
"binding": "AI",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "basics-integration-auxiliary",
33
"main": "src/index.ts",
4+
// compatibility_date is required so we can run `wrangler build`
45
"compatibility_date": "2024-01-01",
56
}

fixtures/vitest-pool-workers-examples/basics-unit-integration-self/test/fetch-integration-self.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ it("dispatches fetch event", async () => {
77
// Importantly, it uses the exact `import("../src").default` instance we could
88
// import in this file as its handler.
99
const response = await SELF.fetch("http://example.com");
10-
expect(await response.text()).toBe("👋 http://example.com");
10+
expect(await response.text()).toBe("👋 http://example.com/");
1111
});

fixtures/vitest-pool-workers-examples/basics-unit-integration-self/test/fetch-unit.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ it("dispatches fetch event", async () => {
1616
const ctx = createExecutionContext();
1717
const response = await worker.fetch(request, env, ctx);
1818
await waitOnExecutionContext(ctx);
19-
expect(await response.text()).toBe("👋 http://example.com");
19+
expect(await response.text()).toBe("👋 http://example.com/");
2020
});
2121

2222
it("calls arbitrary function", () => {
2323
const request = new Request("http://example.com");
24-
expect(greet(request)).toBe("👋 http://example.com");
24+
expect(greet(request)).toBe("👋 http://example.com/");
2525
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "basics-unit-integration-self",
33
"main": "src/index.ts",
4-
"compatibility_date": "2024-01-01",
4+
// don't provide compatibility_date so that vitest will infer the latest one
55
}

fixtures/vitest-pool-workers-examples/container-app/wrangler.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "container-app",
33
"main": "src/index.ts",
4-
"compatibility_date": "2025-04-03",
4+
// don't provide compatibility_date so that vitest will infer the latest one
55
"containers": [
66
{
77
"image": "./Dockerfile",

fixtures/vitest-pool-workers-examples/d1/wrangler.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "d1",
33
"main": "src/index.ts",
4-
"compatibility_date": "2024-01-01",
4+
// don't provide compatibility_date so that vitest will infer the latest one
55
"env": {
66
"production": {
77
"d1_databases": [

fixtures/vitest-pool-workers-examples/durable-objects/wrangler.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "durable-objects",
33
"main": "src/index.ts",
4-
"compatibility_date": "2024-01-01",
4+
// don't provide compatibility_date so that vitest will infer the latest one
55
"durable_objects": {
66
"bindings": [
77
{

0 commit comments

Comments
 (0)