Skip to content

Commit d8a9ee7

Browse files
fixup! fix(vitest-pool-workers): allow miniflare assets options to override wrangler assets options
1 parent a74d04b commit d8a9ee7

6 files changed

Lines changed: 42 additions & 14 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { defineWorkersProject } from "@cloudflare/vitest-pool-workers/config";
2+
3+
export default defineWorkersProject({
4+
test: {
5+
name: "misc-assets",
6+
include: ["test/assets.test.ts"],
7+
poolOptions: {
8+
workers: {
9+
singleWorker: true,
10+
miniflare: {
11+
assets: {
12+
directory: "./public",
13+
binding: "ASSETS",
14+
},
15+
},
16+
wrangler: {
17+
configPath: "./wrangler.assets.jsonc",
18+
},
19+
},
20+
},
21+
},
22+
});

fixtures/vitest-pool-workers-examples/misc/vitest.config.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ export default defineWorkersProject({
77
"CONFIG_NESTED.DEFINED.THING": "[1,2,3]",
88
},
99
test: {
10+
exclude: ["test/assets.test.ts"],
1011
poolOptions: {
1112
workers: {
1213
singleWorker: true,
1314
miniflare: {
14-
assets: {
15-
directory: "./public",
16-
binding: "ASSETS",
17-
},
1815
kvNamespaces: ["KV_NAMESPACE"],
1916
outboundService(request) {
2017
return new Response(`fallthrough:${request.method} ${request.url}`);
2118
},
19+
serviceBindings: {
20+
ASSETS(request) {
21+
return new Response(`assets:${request.method} ${request.url}`);
22+
},
23+
},
2224
workers: [
2325
{
2426
name: "other",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "../node_modules/wrangler/config-schema.json",
3+
"compatibility_date": "2024-01-01",
4+
"assets": {
5+
// This will be overridden by the assets config in vitest.config.ts
6+
// See https://github.com/cloudflare/workers-sdk/issues/9130
7+
"directory": "./does-not-exist",
8+
"binding": "ASSETS",
9+
},
10+
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,4 @@
1414
},
1515
],
1616
},
17-
"assets": {
18-
// This will be overridden by the assets config in vitest.config.ts
19-
// See https://github.com/cloudflare/workers-sdk/issues/9130
20-
"directory": "./does-not-exist",
21-
"binding": "ASSETS",
22-
},
2317
}

fixtures/vitest-pool-workers-examples/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"scripts": {
66
"check:type": "node tsc-all.mjs",
77
"list": "vitest --config vitest.workers.config.ts list",
8-
"test": "vitest --config vitest.workers.config.ts --reporter basic",
8+
"test": "vitest --config vitest.workers.config.ts",
99
"test:ci": "run-script-os",
10-
"test:ci:default": "vitest run --config vitest.workers.config.ts --reporter basic",
11-
"test:ci:win32": "vitest run --config vitest.workers.config.ts --reporter basic --exclude test/sqlite-in-do.test.ts"
10+
"test:ci:default": "vitest run --config vitest.workers.config.ts",
11+
"test:ci:win32": "vitest run --config vitest.workers.config.ts --exclude test/sqlite-in-do.test.ts"
1212
},
1313
"devDependencies": {
1414
"@cloudflare/vitest-pool-workers": "workspace:*",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default ["*/vitest.config.*ts"];
1+
export default ["*/vitest.*config.*ts"];

0 commit comments

Comments
 (0)