// Build the pure-logic tests to ESM and run them with node --test. request.ts // and protocol.ts import nothing from n8n, so this needs only esbuild + node. // node_modules stay external (--packages=external) so the @noble/post-quantum // dynamic import in protocol.ts resolves at runtime instead of being bundled. import { spawnSync } from 'node:child_process'; import { dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; const root = dirname(dirname(fileURLToPath(import.meta.url))); const run = (cmd, args) => spawnSync(cmd, args, { cwd: root, stdio: 'inherit' }); const suites = ['request', 'protocol']; const build = run('npx', [ 'esbuild', ...suites.map((name) => `test/${name}.test.ts`), '--bundle', '--format=esm', '--platform=node', '--packages=external', '--outdir=test-dist', '--out-extension:.js=.mjs', ]); if (build.status !== 0) process.exit(build.status ?? 1); const test = run('node', ['--test', ...suites.map((name) => `test-dist/${name}.test.mjs`)]); process.exit(test.status ?? 1);