Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support electron-mocha #87

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/node_modules
/lib
/npm-debug.log
/coverage
/coverage
/.nyc_output
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Tutorials:
* [Mocha and Istanbul Guide](./docs/HOWTO-istanbul.md)
* [Mocha and JSCoverage Guide](./docs/HOWTO-jscoverage.md)
* [Istanbul and Tape Guide](./docs/HOWTO-tape-not-mocha.md) courtesy [@jessaustin](https://github.com/jessaustin).
* [Electron-mocha and nyc Guide](./docs/HOWTO-electron-mocha.md)
* [Codeship and Coveralls](./docs/HOWTO-codeship-and-coveralls.md)
* [Travis-CI and Coveralls](./docs/HOWTO-travisci-and-coveralls.md)
* [Ignoring code with Pragmas](./docs/pragmas.md)
Expand Down
49 changes: 49 additions & 0 deletions docs/HOWTO-electron-mocha.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Running with [Electron-mocha](https://github.com/jprichardson/electron-mocha)
---------------------------------------------------------------

Contents
========

* [Quick Start with Electron-mocha](#quick-start-with-electron-mocha)
* [Run with NPM](#run-with-npm)

Quick Start with Electron-mocha and Nyc
---------------------------------------

Electron-mocha is an awesome project allowing you to test your sources within electron processes, either main or renderer.

[Nyc](https://github.com/istanbuljs/nyc) is the latest Istanbul command line interface, which simplifies a lot instrumentation and reporting.

Assuming you have a coffee-script/electron project with tests cases stored in /test, `cd` to your project and run:

npm install --save-dev coffee-coverage nyc electron-mocha

Now you're ready to run your tests

./node_modules/.bin/nyc --reporter lcov --reporter text ./node_modules/.bin/electron-mocha --renderer --compilers coffee:coffee-script/register -r coffee-coverage/register-istanbul -R spec test/**/*.coffee

Run with NPM
============

Save your mocha options in `/test/mocha.opts`:

```sh
--require coffeescript/register
--require coffee-coverage/register-istanbul
--reporter spec
```

In package.json, add:

```json
"scripts": {
"test": "nyc electron-mocha --renderer test/**/*.coffee"
}
...
"nyc": {
"reporter": ["lcov","text"]
},
...
``

now you can run `npm test` to run your tests and generate a coverage report, both in console and in `coverage/lcov-report/index.html`
Loading