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
19 stars 4 forks source link

The "options.context" property must be an vm.Context. #33

Open unional opened 6 months ago

unional commented 6 months ago
TypeError: The "options.context" property must be an vm.Context. Received an instance of Object

          at Runtime.loadEsmModule (../../node_modules/.pnpm/jest-runtime@29.7.0/node_modules/jest-runtime/build/index.js:516:20) 

Getting this error when using NODE_OPTIONS=--experimental-vm-modules.

It could be a non-issue as electron doesn't really support ESM yet (although latest version starts supporting it), but opening this issue for reference.

kayahr commented 3 weeks ago

I don't think that it will magically work out of the box by just upgrading Electron in the future. jest-electron-runner is pretty much tied to CJS require calls and I don't think I will be able to fix this. But pull requests are always welcome.

Actually for ESM projects I strongly recommend abandoning Jest and jest-electron-runner and switch to Vitest and use its Browser Mode to run tests in a headless Chromium.