{"id":13767038,"url":"https://github.com/jprichardson/electron-mocha","last_synced_at":"2025-05-14T15:07:31.545Z","repository":{"id":1872728,"uuid":"38903992","full_name":"jprichardson/electron-mocha","owner":"jprichardson","description":"Run Mocha tests in Electron","archived":false,"fork":false,"pushed_at":"2025-01-16T12:20:12.000Z","size":1543,"stargazers_count":345,"open_issues_count":9,"forks_count":63,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-02T14:08:21.670Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jprichardson.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2015-07-10T22:03:07.000Z","updated_at":"2025-01-16T12:20:07.000Z","dependencies_parsed_at":"2024-01-02T21:20:10.415Z","dependency_job_id":"e3bfd67c-0984-4fb8-a0d5-11b80765efde","html_url":"https://github.com/jprichardson/electron-mocha","commit_stats":{"total_commits":409,"total_committers":38,"mean_commits":"10.763157894736842","dds":0.2542787286063569,"last_synced_commit":"f704452b30a7db672b1064db0788c0f32097441c"},"previous_names":[],"tags_count":90,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jprichardson%2Felectron-mocha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jprichardson%2Felectron-mocha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jprichardson%2Felectron-mocha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jprichardson%2Felectron-mocha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jprichardson","download_url":"https://codeload.github.com/jprichardson/electron-mocha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253939140,"owners_count":21987411,"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":[],"created_at":"2024-08-03T16:01:03.893Z","updated_at":"2025-05-14T15:07:31.524Z","avatar_url":"https://github.com/jprichardson.png","language":"JavaScript","funding_links":[],"categories":["Library","Tools"],"sub_categories":["Testing","Using Electron"],"readme":"electron-mocha\n==============\n[![npm](https://img.shields.io/npm/v/electron-mocha.svg?maxAge=2592000)](https://www.npmjs.com/package/electron-mocha)\n\nMocha testing in [Electron](https://electronjs.org). This project has\ntwo main value propositions:\n\n1. You can now test any JavaScript app in a real browser environment.\n2. You can now test your Electron apps!\n\n\n## Install\n\n    npm i -g electron-mocha\n\n\n## Usage\n\n### Install Electron\n\nFirst, you need to install Electron. You can either run:\n\n    npm i -g electron\n\nand then `electron` will be added to your path. Or, you\ncan download a version from https://github.com/electron/releases and\nthen set an environment variable `ELECTRON_PATH` pointing to the binary.\nNote if you're using Mac OS X, the path would be to the actual executable\nand not the app directory e.g. `/Applications/Electron.app/Contents/MacOS/Electron`.\n\n### Run Tests\n\n`electron-mocha` is almost a drop-in replacement for the regular `mocha` command,\nwith these additional options:\n\n    --renderer              Run tests in renderer process              [boolean]\n    --require-main, --main  Require module in main process             [array]\n    --script                Load module in renderer via script tag     [array]\n    --interactive           Show renderer tests in persistent window   [boolean]\n    --url, --index          Load custom URL in renderer                [string]\n    --preload               Load module during renderer preload        [string]\n    --window-config         Supply custom Electron window options      [string]\n    -W, --warnings          Print renderer warnings to console         [boolean]\n    --show-window           Show the window during tests               [boolean\n\nThe `window-config` switch must point to a JSON file or to a JavaScript module that exports\nan options object. For more information, check out the\n[Electron API docs](https://www.electronjs.org/docs/api/browser-window#new-browserwindowoptions).\n\nFor the full list of available options, see `electron-mocha --help`.\n\n#### Examples\n\n    electron-mocha\n\nThis runs all tests in your `test` directory in the\n[main process](https://github.com/electron/electron/blob/master/docs/tutorial/application-architecture.md#main-and-renderer-processes).\n\n    electron-mocha --renderer\n\nThis runs all tests in your `test` directory in a\n[renderer process](https://github.com/electron/electron/blob/master/docs/tutorial/application-architecture.md#main-and-renderer-processes).\nThis means that you have access to the entirety of the DOM, web storage, etc. This is because it's actually\nrunning in a [Chromium](https://en.wikipedia.org/wiki/Chromium_(web_browser)) process.\n\n### Using for CI\n\nIn most Linux CI environments you'll need to use XFVB to run your tests. Either start the appropriate XVFB service or use `xvfb-run`.\n\n#### WebGL Tests\n\nIf you are writing tests for WebGL programs and you cannot get a WebGL contexts,\nthis may be because the environment doesn't have GPU support.\nYou can pass **--ignore-gpu-blacklist** to Electron to bypass it:\n\n* command\n```shell\nelectron-mocha --main ignore-gpu-blacklist.js\n```\n* ignore-gpu-blacklist.js\n```js\nconst { app } = require('electron');\napp.commandLine.appendSwitch('ignore-gpu-blacklist');\n```\n\n###  Debugger Support\n\nUse the `--inspect` or `--inspect-brk` options to enable Electron's debugger.\nWhen using `--renderer` this will show the test-runner window dev-tools, including\na debugger (so you do not need to attach a node-inspector).\n\nNote that the window will close automatically when the tests have finished,\ntherefore this option should be used in combination with `debugger` statements\nanywhere in your tests or code.\n\nAlternatively, you can use the `--interactive` option which will keep the window\nopen after your tests have run (you can reload the window to run the tests again),\nto give you the opportunity to set breakpoints using the dev-tools inspector.\n\nTo debug the main process, you will need to\n[start a node-inspector separately](https://nodejs.org/en/docs/inspector/).\n\n### Code Coverage\n\nYou can use `electron-mocha` to collect code coverage data in both Electron's\nmain and renderer processes. To do this, you will need to instrument your code,\nrun the tests on the instrumented code, and save the coverage stats after all\ntests have finished.\n\nFor examples, [see this thread](https://github.com/jprichardson/electron-mocha/issues/135#issuecomment-464160861)\n\n\nLicense\n-------\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjprichardson%2Felectron-mocha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjprichardson%2Felectron-mocha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjprichardson%2Felectron-mocha/lists"}