Skip to content
⚛️The easiest way to run and debug test cases in electron with jest.
TypeScript CSS HTML JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github revert: Coveralls Nov 6, 2019
__tests__ fix(pending): add pending status icon Dec 12, 2019
src fix: electron window should display error-prone source codes instead … Jan 20, 2020
.gitignore chore: init Sep 14, 2019
LICENSE docs: update README for no-sandbox Jan 16, 2020
environment.js chore: init Sep 14, 2019
package.json docs: update README for no-sandbox Jan 16, 2020
runner.js chore: init Sep 14, 2019
tsconfig.json feat(react): add react test support Dec 7, 2019


Easiest way to run jest unit test cases in electron.

When we run unit test in Jest, it is actually running in the node environment, or virtual browser environment(e.g. JSDOM) mocked by NodeJS. Sometimes we need a lot of Jest mocks for running code with no throw, such as: jest-canvas-mock, jest-storage-mock, @jest/fake-timers and so on. This is solved by Jest-Electron.

Build Status npm npm

  1. Technological ecology of Jest.
  2. Complete and real browser environment.
  3. Multi-renderer for running performance.
  4. Running and debug is better then mock.


  • Add into devDependencies
$ npm i --save-dev jest-electron
  • Update Jest config
  "jest": {
+    "runner": "jest-electron/runner",
+    "testEnvironment": "jest-electron/environment"

Notice: update the runner configure, not testRunner.


Those will be helpful when run test case with jest-electron.


Run test cases with jest-electron for continuous integration.

  • GitHub action

Running on macOS will be ok.

- runs-on: ubuntu-latest
+ runs-on: macOS-latest
  • travis

Update .travis.yml with electron supported.

language: node_js
  - "8"
  - "9"
  - "10"
  - "11"
  - "12"
+ addons:
+   apt:
+     packages:
+       - xvfb
+ install:
+   - export DISPLAY=':99.0'
+   - Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
+   - npm install
  - npm run test


  • debug mode

Keep the electron browser window for debugging, set process env DEBUG_MODE=1.

  • no sandbox

Run electron with --no-sandbox, set process env JEST_ELECTRON_NO_SANDBOX=1.




You can’t perform that action at this time.