Open kierans opened 7 years ago
It turns out this is an issue with Browserify, which is used to package Mocha for the browser. Mocha simply assigns global.mocha = ...
and Browserify injects the first defined of global
, self
and window
as global
. In most browsers, global
isn't defined, so window.mocha
ends up being defined, which is what you want. But in NW.js both global
and window
are defined (because NW.js puts global
on window.global
) so Mocha ends up defined at global.mocha
which is the wrong context. It also defines global.describe
, global.it
, etc. which in the browser should all be on window
to work.
The issue is being tracked here: https://github.com/substack/insert-module-globals/pull/48
I've created https://github.com/kierans/karma-nodewebkit-mocha as a wrapper for karma-mocha
until the underlying bug is fixed.
Just like this question I'm trying to run Mocha tests via Karma in NW.js.
However my tests aren't running as
window.mocha
isn't defined.Is it possible to do something like
window.mocha = window.mocha || require("mocha")
in the Adapter? Any other tips/suggestions.