kayahr / jest-electron-runner

Custom test runner for Jest that allows tests to be run in Electron environment
https://www.npmjs.com/package/@kayahr/jest-electron-runner
MIT License
20 stars 4 forks source link

Cannot find module 'node:fs' #13

Closed kayahr closed 1 year ago

kayahr commented 1 year ago
    Also I get this error sometimes.
Error: Cannot find module 'node:fs'
Require stack:
- /home/emobe/projects/pixijs/node_modules/@kayahr/jest-electron-runner/lib/main/electron/runTest.js
- /home/emobe/projects/pixijs/node_modules/@kayahr/jest-electron-runner/lib/main/electron/rpc/JestWorkerRPC.js
- /home/emobe/projects/pixijs/node_modules/@kayahr/jest-electron-runner/lib/main/electron/electron_process_injected_code.js
- /home/emobe/projects/pixijs/node_modules/electron/dist/resources/default_app.asar/main.js
- 
    at Module._resolveFilename (internal/modules/cjs/loader.js:887:15)
    at Function.n._resolveFilename (electron/js2c/browser_init.js:261:1128)
    at Module._load (internal/modules/cjs/loader.js:732:27)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12684)
    at Module.require (internal/modules/cjs/loader.js:959:19)
    at require (internal/modules/cjs/helpers.js:88:18)

Originally posted by @Emobe in https://github.com/kayahr/jest-electron-runner/issues/12#issuecomment-1353331525

kayahr commented 1 year ago

@Emobe I guess, you are using Node.js older than v18? Looks like these "node:*" imports only work in Node 18 and newer. Didn't know that, sorry. I changed them back to normal imports and published a new version.

So with v29.3.1 this should work now again with older Node.js versions (Or older Electron versions which have some Node version embedded)