Skip to content

Commit b7e6966

Browse files
bchapuisclaude
andcommitted
Fix CI: stub @cloudflare/sandbox and @cloudflare/containers in tests
workerd cannot resolve @cloudflare/containers (imported by @cloudflare/sandbox) at runtime. Alias both to an empty stub module in vitest config to avoid module resolution failures in tests that don't exercise these bindings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1e78819 commit b7e6966

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Empty stub for packages that can't be resolved in the workerd test environment.
2+
// Used by vitest.config.ts resolve.alias to avoid module resolution failures.
3+
export default {};

apps/api/vitest.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1+
import path from "node:path";
12
import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config";
23

4+
const emptyStub = path.resolve(__dirname, "test/stubs/empty-module.ts");
5+
36
export default defineWorkersConfig({
7+
resolve: {
8+
alias: {
9+
// @cloudflare/sandbox imports @cloudflare/containers which workerd
10+
// cannot resolve at runtime. Stubbing both avoids module resolution
11+
// failures in tests that don't exercise these bindings.
12+
"@cloudflare/sandbox": emptyStub,
13+
"@cloudflare/containers": emptyStub,
14+
},
15+
},
416
test: {
517
setupFiles: ["./test/setup.ts"],
618
testTimeout: 30000,

0 commit comments

Comments
 (0)