Conversation
package.json
Outdated
| "chai": "^3.0.0", | ||
| "coveralls": "^2.11.2", | ||
| "electron": "1.6.11", | ||
| "electron-mocha": "4.0.0", |
There was a problem hiding this comment.
I took the liberty to add them as dev dependencies, in order to test them
| "coverage-report": "istanbul report text-summary lcov", | ||
| "prepublish": "npm run test", | ||
| "test": "npm run build && nyc mocha --growl", | ||
| "test:electron": "npm run build && nyc electron-mocha --renderer test/**/*.coffee", |
There was a problem hiding this comment.
mocha & electron-mocha both use mocha.opts file.
I added test:electron command to run the full test suite in electron context, which was a simple and good-enough test
But because electron-mocha doesn't support --growl flag, I had to move it above.
| if (process.env.NYC_CONFIG) { | ||
| var config = JSON.parse(process.env.NYC_CONFIG); | ||
| outFile = resolve(config.cwd, config.tempDirectory, process.env.NYC_ROOT_ID + '.json'); | ||
| } |
There was a problem hiding this comment.
This makes nyc aware of the report produced by coffee-coverage.
It generates the outFile in the proper place so nyc can parse it during its report phase.
| console.error "Failed to write coverage data", err.stack ? err | ||
| if global.window? | ||
| # support electron-mocha end of run | ||
| window.addEventListener 'unload', report |
There was a problem hiding this comment.
This is required to support electron-mocha, because this hook don't have access to process's exit event.
|
|
||
| it "should exclude files quickly", (done) -> | ||
| # Can't run benchmark on electron-mocha | ||
| return @skip() if global.window? |
There was a problem hiding this comment.
For an unknown reason, Benchmark is undefined when running this with electron-mocha.
As the intent was only to check that coverage was working, I though this could be acceptable to skip it.
2 similar comments
|
Hello @jwalton. I'm sorry, but I couldn't find any way to increase coverage on my code. Adding |
Allow NYC usage with electron-mocha
Between coffeescript 2.0.2 and 2.3.1, an internal changes was introduce, and AST nodes don't necessary have locationData attached
|
Hello here! It's been a while since I had to use coffee,-coverage and electron-mocha. Between coffeescript 2.0.2 and 2.3.1 (the latest at the moment), an internal changes was introduce, and AST nodes don't necessary have I've added a test to replicate this situation, it occurs when using blocks such as single-line for loops. |
Electron-mocha is a special flavour of mocha that runs test within Electron context.
It works fine with nyc, as long as instrumentation is done by using mocha hooks, like coffee-coverage does.
But I found out it requires some small adaptation to make it works.