test: Resolve test-config module aliases dynamically instead of hardcoding versions (no-changelog) (#31621)
Some checks are pending
Build: Benchmark Image / build (push) Waiting to run
CI: Master (Build, Test, Lint) / Build for Github Cache (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (22.22.3) (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (24.15.0) (push) Waiting to run
CI: Master (Build, Test, Lint) / Lint (push) Waiting to run
CI: Master (Build, Test, Lint) / Performance (push) Waiting to run
CI: Master (Build, Test, Lint) / Notify Slack on failure (push) Blocked by required conditions
Util: Sync API Docs / sync-public-api (push) Waiting to run

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matsu 2026-06-03 10:44:01 +03:00 committed by GitHub
parent 25766222b8
commit 3ea606ac60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 17 deletions

View File

@ -16,13 +16,12 @@ export default mergeConfig(
// Workspace deps CJS-require zod while tests ESM-import it, so
// `schema instanceof ZodSchema` in src/converters/tool.ts fails across the
// two. Pin the top-level `zod` import to the CJS file so both share one
// module instance. Subpaths like `zod/v4` keep their normal resolution.
// module instance. `require.resolve` follows zod's `require` export condition,
// so it tracks the installed (catalog) version automatically. Subpaths like
// `zod/v4` keep their normal resolution.
{
find: /^zod$/,
replacement: path.resolve(
__dirname,
'../../../node_modules/.pnpm/zod@3.25.67/node_modules/zod/dist/cjs/index.js',
),
replacement: require.resolve('zod'),
},
],
},

View File

@ -50,13 +50,12 @@ export default mergeConfig(
// Workspace deps CJS-require zod while test files ESM-import it, so
// `instanceof` checks (e.g. in sanitize-mcp-schemas) fail across the two
// module instances. Pin the top-level `zod` import to the CJS file so all
// code paths share one instance. Subpaths like `zod/v4` resolve normally.
// code paths share one instance. `require.resolve` follows zod's `require`
// export condition, so it tracks the installed (catalog) version
// automatically. Subpaths like `zod/v4` resolve normally.
{
find: /^zod$/,
replacement: path.resolve(
__dirname,
'../../../node_modules/.pnpm/zod@3.25.67/node_modules/zod/dist/cjs/index.js',
),
replacement: require.resolve('zod'),
},
],
},

View File

@ -12,7 +12,10 @@ export default mergeConfig(
alias: {
'@utils': path.resolve(__dirname, './utils'),
'@nodes-testing': path.resolve(__dirname, '../../core/nodes-testing'),
'n8n-workflow': path.resolve(__dirname, '../../workflow/dist/cjs/index.js'),
// Pin n8n-workflow to its CJS build so the single module instance is shared
// across CJS-required workspace deps and ESM-imported test code.
// `require.resolve` follows the `require` export condition (the CJS dist).
'n8n-workflow': require.resolve('n8n-workflow'),
},
},
}),

View File

@ -16,14 +16,12 @@ export default mergeConfig(
// `./dist/cjs/index.js` for `require`) — two separate files with two separate
// `ZodType` classes. @n8n/config dist CJS-requires zod, test files ESM-import
// it, and `instanceof` fails between them. Pin the top-level `zod` import to the
// CJS file so both code paths share a single module instance. Subpaths like
// `zod/v4` keep their normal resolution.
// CJS file so both code paths share a single module instance. `require.resolve`
// follows zod's `require` export condition, so it tracks the installed (catalog)
// version automatically. Subpaths like `zod/v4` keep their normal resolution.
{
find: /^zod$/,
replacement: path.resolve(
__dirname,
'../../node_modules/.pnpm/zod@3.25.67/node_modules/zod/dist/cjs/index.js',
),
replacement: require.resolve('zod'),
},
],
},