hi, so when i include expect.js over the --require parameter, it doesn't work. i also tried putting this option on mocha.opts
--require expect.js
but i still getting "ReferenceError: expect is not defined"
does --require only work with should.js? or what do i missing?
the --require option doesn't inject/define variable(s) for you. what the --require option does for you is (excuse the crude example):
require('expect');
[ your code here ]
not:
var expect = require('expect');
[ your code here ]
so, what would it be good for? except for including "should.js" on the tests
it's not good for much other than should really haha, I would remove it now if people weren't already using it
This works for me (in node):
// inject.js
global.expect = require('expect.js');
// test/some_test.js
describe('foo', function(){
it('should be foo', function(){
expect('foo').to.be('foo');
});
});
mocha --require "./inject" "test/some_test.js"
This allows me to use the same test in browsers using the _expect_ package of _bower_, which provides only a expect function within the global namespace.
Thank you @schnittstabil.
Thank you @schnittstabil :cake:
@schnittstabil where is the inject script called? Does mocha have an option for passing scripts? I thought it was only Mocha.opts. Feel free to tell me to RTFM if it is in there.
Most helpful comment
the
--requireoption doesn't inject/define variable(s) for you. what the--requireoption does for you is (excuse the crude example):not: