mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 06:11:37 +00:00
test(vitest): route zod and undici through Bun-safe test resolutions (#114520)
This commit is contained in:
committed by
GitHub
parent
dd472deab4
commit
0f879595d4
@@ -160,6 +160,21 @@ export const sharedVitestConfig = {
|
||||
envDir: false as const,
|
||||
resolve: {
|
||||
alias: [
|
||||
{
|
||||
// Route bare `zod` through a runtime shim (same pattern as the
|
||||
// discord-api-types shims below): zod's own entry re-exports `z` as a
|
||||
// namespace binding, which Bun's linker drops under Vitest's loader
|
||||
// hooks. The shim exposes the identical surface on Node and Bun.
|
||||
find: /^zod$/u,
|
||||
replacement: path.join(repoRoot, "test", "vitest", "zod-runtime.ts"),
|
||||
},
|
||||
{
|
||||
// Bun substitutes its built-in fetch shim for bare `undici`, whose
|
||||
// MockAgent is a non-functional stub; pin the real package so
|
||||
// mock-http interception works. Node resolves to this file anyway.
|
||||
find: /^undici$/u,
|
||||
replacement: path.join(repoRoot, "node_modules", "undici", "index.js"),
|
||||
},
|
||||
{
|
||||
find: "discord-api-types/v10",
|
||||
replacement: path.join(repoRoot, "test", "vitest", "discord-api-types-v10-runtime.ts"),
|
||||
|
||||
10
test/vitest/zod-runtime.ts
Normal file
10
test/vitest/zod-runtime.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
// Test-only zod entry: zod's real index.js re-exports the `z` namespace via
|
||||
// `import * as z; export { z }`, which Bun's module linker drops when Vitest's
|
||||
// loader hooks are active (named `z` arrives undefined). Re-exporting through a
|
||||
// const binding links correctly on both Node and Bun; the exposed surface is
|
||||
// identical to `zod` (zod/v4 is the same classic API), so Node is unchanged.
|
||||
import * as zNamespace from "zod/v4";
|
||||
|
||||
export * from "zod/v4";
|
||||
export const z = zNamespace;
|
||||
export default zNamespace;
|
||||
Reference in New Issue
Block a user