@@ -2,6 +2,7 @@ import { writeFile } from 'node:fs/promises';
22import test from 'ava' ;
33import mock from 'mock-fs' ;
44import path from 'node:path' ;
5+ import { createRequire } from 'node:module' ;
56import Project , { generateWorkflow } from '@openfn/project' ;
67import { createMockLogger } from '@openfn/logger' ;
78import createLightningServer from '@openfn/lightning-mock' ;
@@ -29,15 +30,24 @@ const ENDPOINT = `http://localhost:${port}`;
2930const projectYaml = myProject_yaml . replace ( 'https://app.openfn.org' , ENDPOINT ) ;
3031const two_workflows_yaml = twowfs . replace ( 'https://app.openfn.org' , ENDPOINT ) ;
3132
33+ const require = createRequire ( import . meta. url ) ;
34+
3235const mockFs = ( paths : Record < string , string > ) => {
3336 // ensure this path is available to pnpm (needed by deps for some reason??)
3437 // Note: loading all of pnpm takes ~7 seconds per test
3538 // this workaround cuts out that delay entirely
3639 const iconv = path . resolve (
3740 '../../node_modules/.pnpm/iconv-lite@0.4.24/node_modules/iconv-lite/encodings'
3841 ) ;
42+ // undici v8 reads its llhttp WASM from disk on the first request, so keep
43+ // that dir visible or fetches to the mock server fail with ENOENT
44+ const undiciLlhttp = path . join (
45+ path . dirname ( require . resolve ( 'undici' ) ) ,
46+ 'lib/llhttp'
47+ ) ;
3948 mock ( {
4049 [ iconv ] : mock . load ( iconv , { } ) ,
50+ [ undiciLlhttp ] : mock . load ( undiciLlhttp , { } ) ,
4151 ...paths ,
4252 } ) ;
4353} ;
0 commit comments