javascript - Webstorm IDE and mocha tests using global.expect -
i run following command run mocha tests:
./node_modules/.bin/mocha --require ./my.js
and in js file, using sinon , expect spyon...
global.expect = require('must'); global.sinon = require('sinon');
how configure mocha task runner use external file. using --require ./my.js
still see referenceerror: spyon not defined
any thoughts on this?
required modules resolved relative working directory specified in "working directory" field of mocha run/debug configuration.
here configuration works me:
working directory: c:\webstormprojects\mocha_sinon mocha package: c:\webstormprojects\mocha_sinon\node_modules\mocha options: --require ./with_req/util.js test directory: c:\webstormprojects\mocha_sinon\with_req
my spec file:
var eventemitter = require('events').eventemitter; var should = require('should'); describe('eventemitter', function(){ describe('#emit()', function(){ it('should invoke callback', function(){ var spy = sinon.spy() , emitter = new eventemitter; emitter.on('foo', spy); emitter.emit('foo'); spy.called.should.equal.true; }) }) })
util.js;
global.sinon = require('sinon');
Comments
Post a Comment