Skip to content

Commit 62f8d82

Browse files
authored
docs(guide): Instructions for using jest with electron's version of node. (#1332)
1 parent 462f8f6 commit 62f8d82

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/guide/testingAndDebugging.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,14 @@ testWithSpectron(
7979
:::warning
8080
Make sure to update spectron along with electron. See the [spectron version map](https://github.com/electron-userland/spectron#version-map) to determine what version of spectron you should be using.
8181
:::
82+
83+
### Regular Unit Tests Using Electron's Version of Node
84+
85+
If you have a native dependency (like better-sqlite3) you might have problems running `jest` and get native dependency node version conflict errors.
86+
87+
To resolve this, run your Jest tests in the same version of node that electron uses. It's a bit hacky, but this works well:
88+
89+
```
90+
TEST_MODE=1 ELECTRON_RUN_AS_NODE=1 ./node_modules/electron/dist/electron ./node_modules/jest/bin/jest.js
91+
```
92+
You can set this as `test:unit` in your package.json to use this by default instead of the default command. This is used by [Beekeeper Studio](https://github.com/beekeeper-studio/beekeeper-studio).

0 commit comments

Comments
 (0)