# @jest-runner/electron

> Jest runner that spawns atom/electron workers instead of node

Latest version **3.0.1** (published 2021-03-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jest-runner/electron
pnpm add @jest-runner/electron
yarn add @jest-runner/electron
bun add @jest-runner/electron
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2021-03-16 |
| First published | 2018-08-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 40.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 189 |
| Author | Aaron Abramov |
| Maintainers | aaronabramov |

## Links

- npm: https://www.npmjs.com/package/@jest-runner/electron
- Repository: https://github.com/facebook-atom/jest-electron-runner
- Issues: https://github.com/facebook-atom/jest-electron-runner/issues
- npm.io page: https://npm.io/package/@jest-runner/electron

## Dependencies (8)

- [throat](https://npm.io/package/throat.md) ^4.1.0
- [jest-mock](https://npm.io/package/jest-mock.md) ^25.0.0
- [jest-util](https://npm.io/package/jest-util.md) ^25.0.0
- [jest-runner](https://npm.io/package/jest-runner.md) ^25.0.0
- [jest-runtime](https://npm.io/package/jest-runtime.md) ^25.0.0
- [jest-haste-map](https://npm.io/package/jest-haste-map.md) ^25.0.0
- [@jest-runner/rpc](https://npm.io/package/@jest-runner/rpc.md) ^3.0.0
- [@jest-runner/core](https://npm.io/package/@jest-runner/core.md) ^3.0.0

## Recent versions

- 3.0.1 (latest) — 2021-03-16
- 3.0.0 — 2020-05-04
- 2.0.3 — 2019-12-03
- 2.0.2 — 2019-06-25
- 2.0.1 — 2019-06-05
- 2.0.0 — 2019-05-29
- 1.1.1 — 2019-02-25
- 1.1.0 — 2019-02-22
- 1.0.3 — 2019-01-31
- 1.0.2 — 2019-01-31
- 1.0.1 — 2019-01-30
- 1.0.0 — 2019-01-29
- 0.2.2 — 2019-01-12
- 0.2.0 — 2019-01-12
- 0.1.0 — 2018-11-02
- … 15 more at https://npm.io/package/@jest-runner/electron/versions

## README

[![CircleCI](https://circleci.com/gh/facebook-atom/jest-electron-runner.svg?style=svg)](https://circleci.com/gh/facebook-atom/jest-electron-runner)


## Jest electron runner
A custom test runner for Jest that runs tests inside an [electron](https://electronjs.org/) main or renderer process providing the following benefits:

- Main
  - all electron instance modules (ipc, app, etc)

- Renderer
  - full access to a browser environment without the need for jsdom or similar modules


## Getting Started

*NOTE: for `jest@23` use the older version `~@jest-runner/electron@0.2.2`*

1. Install jest electron runner `yarn add @jest-runner/electron --dev`
2. Add one of these lines to your jest config (in `package.json` or inside your `jest.config.js` file), depending on the process you wish to test. If you wish to test them in parallel, see the tips section below.

    - Main process
    ```js
        {
          // ...
          runner: '@jest-runner/electron/main',
          testEnvironment: 'node',
        }
    ```
    - Renderer Process
    ```js
        {
          // ...
          runner: '@jest-runner/electron',
          testEnvironment: '@jest-runner/electron/environment',
        }
    ```
3. run jest!


<h1 align="center">
    <img src="https://raw.githubusercontent.com/aaronabramov/gifs/master/jest_electron_runner_seutup.gif" />
</h1>

### Debugging
Normally jest-electron-runner runs a headless instance of electron when testing the renderer process. You may show the UI by adding this to your test:
```js
require('electron').remote.getCurrentWindow().show();
```

### Tips
- The main process runner can be used to test any non-browser related code, which can speed up tests roughly 2x.
- To run the main and renderer process tests in parallel, you can provide a config object to the `projects` array in a jest javascript config file like so:
```js
// jest.config.js
const common = require('./jest.common.config')

module.exports = {
  projects: [
    {
      ...common,
      runner: '@jest-runner/electron/main',
      testEnvironment: 'node',
      testMatch: ['**/__tests__/**/*.(spec|test).ts']
    },
    {
      ...common,
      runner: '@jest-runner/electron',
      testEnvironment: '@jest-runner/electron/environment',
      testMatch: ['**/__tests__/**/*.(spec|test).tsx']
    }
  ]
}
```

### [Code of Conduct](https://code.facebook.com/codeofconduct)

Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read [the full text](https://code.facebook.com/codeofconduct) so that you can understand what actions will and will not be tolerated.

### [Contributing Guide](CONTRIBUTING.md)

Read our [contributing guide](CONTRIBUTING.md) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to Jest.

## License

[MIT licensed](./LICENSE).

---
_Source: https://npm.io/package/@jest-runner/electron · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
