{"id":22541360,"url":"https://github.com/kayahr/jest-electron-runner","last_synced_at":"2025-04-09T21:50:30.205Z","repository":{"id":42535529,"uuid":"412435003","full_name":"kayahr/jest-electron-runner","owner":"kayahr","description":"Custom test runner for Jest that allows tests to be run in Electron environment","archived":false,"fork":false,"pushed_at":"2024-04-04T19:51:07.000Z","size":1731,"stargazers_count":19,"open_issues_count":6,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-04T20:52:08.960Z","etag":null,"topics":["electron","jest","test-runner","testing"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@kayahr/jest-electron-runner","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"facebook-atom/jest-electron-runner","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kayahr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"kayahr","custom":"https://paypal.me/kayaahr/"}},"created_at":"2021-10-01T11:11:36.000Z","updated_at":"2024-04-14T22:22:53.681Z","dependencies_parsed_at":"2023-12-01T17:25:59.476Z","dependency_job_id":"228539e9-632c-47f3-b084-cbb0864ddaa1","html_url":"https://github.com/kayahr/jest-electron-runner","commit_stats":{"total_commits":204,"total_committers":20,"mean_commits":10.2,"dds":0.5784313725490196,"last_synced_commit":"33c4e34b055bb3352dd850a10f13745c6c44de68"},"previous_names":[],"tags_count":65,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayahr%2Fjest-electron-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayahr%2Fjest-electron-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayahr%2Fjest-electron-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayahr%2Fjest-electron-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kayahr","download_url":"https://codeload.github.com/kayahr/jest-electron-runner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248119404,"owners_count":21050754,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["electron","jest","test-runner","testing"],"created_at":"2024-12-07T12:15:33.377Z","updated_at":"2025-04-09T21:50:30.199Z","avatar_url":"https://github.com/kayahr.png","language":"TypeScript","funding_links":["https://github.com/sponsors/kayahr","https://paypal.me/kayaahr/"],"categories":[],"sub_categories":[],"readme":"# Jest Electron Runner\n\n| :warning: This project is no longer maintained because the author switched from Jest to [Vitest](https://vitest.dev/) :warning: |\n| ------------------------------------------------------------------------------------------------------------------------------- |\n\nA custom test runner for Jest that runs tests inside an [electron](https://electronjs.org/) main or renderer process providing the following benefits:\n\n- Main\n  - all electron instance modules (ipc, app, etc)\n\n- Renderer\n  - full access to a browser environment without the need for jsdom or similar modules\n\nThis project is a fork of Facebook's [@jest-runner/electron](https://github.com/facebook-atom/jest-electron-runner) which seems to be no longer maintained, was archived on Github and is not working with newer Jest versions. I simplified the project, converted it from Flow to TypeScript and made it compatible to Jest 27 and newer.\n\n\n## Getting Started\n\n1. Install jest electron runner with `npm i --save-dev @kayahr/jest-electron-runner`\n2. 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.\n\n    - Main process\n        ```json\n        {\n            \"runner\": \"@kayahr/jest-electron-runner/main\",\n            \"testEnvironment\": \"node\"\n        }\n        ```\n    - Renderer Process\n        ```json\n        {\n            \"runner\": \"@kayahr/jest-electron-runner\",\n            \"testEnvironment\": \"@kayahr/jest-electron-runner/environment\"\n        }\n        ```\n3. Run jest.\n\n## Configuration\n\njest-electron-runner can be configured through test environment options like this:\n\n```json\n{\n    \"runner\": \"@kayahr/jest-electron-runner\",\n    \"testEnvironment\": \"@kayahr/jest-electron-runner/environment\",\n    \"testEnvironmentOptions\": {\n        \"electron\": {\n            \"options\": [\n                \"no-sandbox\",\n                \"ignore-certificate-errors\",\n                \"force-device-scale-factor=1\"\n            ],\n            \"disableHardwareAcceleration\": false\n        }\n    }\n}\n```\n\nThe test environment options shown in the above example are the default options. You can override these defaults as you like. If you want to remove a value-less electron option then prepend it with an exclamation mark (i.E. `!ignore-certificate-errors`).\n\nThe electron options can be any command-line option supported by Electron. The options can also be specified with the environment variable `ELECTRON_OPTIONS`.\n\nExample:\n\n```sh\nELECTRON_OPTIONS=\"--disable-webgl --enable-unsafe-webgpu\"\n```\n\n## Debugging\nNormally 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:\n```js\n// ES:\n(await import(\"@electron/remote\")).getCurrentWindow().show();\n\n// CommonJS:\nrequire(\"@electron/remote\").getCurrentWindow().show();\n```\n\n## Tips\n- The main process runner can be used to test any non-browser related code, which can speed up tests roughly 2x.\n- To run the main and renderer process tests in parallel, you can provide a config object to the `projects` array in the jest configuration:\n    ```json\n    {\n        \"projects\": [\n            {\n                \"runner\": \"@kayahr/jest-electron-runner/main\",\n                \"testEnvironment\": \"node\"\n            },\n            {\n                \"runner\": \"@kayahr/jest-electron-runner\",\n                \"testEnvironment\": \"@kayahr/jest-electron-runner/environment\"\n            }\n        ]\n    }\n    ```\n\n## License\n\n[MIT licensed](./LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkayahr%2Fjest-electron-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkayahr%2Fjest-electron-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkayahr%2Fjest-electron-runner/lists"}