Closed AJMiller closed 6 years ago
Hm... Strange. I'll check it
I put this:
describe('myFunction', () => {
def('param', true);
subject('fireFunction', () => $param);
context('when the param is false', () => {
def('param', false);
it(() => is.expected.to.eql(false));
});
});
in my tests and it works.
Could you please clarify what version of mocha, chai and bdd-lazy-var you use?
Do you have global.expect = chai.expect
somewhere in configuration?
This shorthand functions expect that expect
function is available in global
namespace
Thanks for the quick reply @stalniy. I'll take a look into it and report back. I didn't see that line in our codebase on a quick search, and I didn't see it mentioned in the installation steps for bdd-lazy-var
.
Versions: Mocha: 5.2.0 Chai: 4.1.2 Bdd-lazy-var: 2.4.0
One difference I did notice is that your subject returns the value directly, where my example has the subject
executing a function. Would that make a difference?
Having expect
On global level is a common practice. Jest & jasmine sets own expect implementation into global scope. The only exception is chai but usually people export chai.expect to global scope as well and use it everywhere in tests
Update bdd-lazy-var to the latest version it’s 2.4.4
thanks @stalniy. Adding the following to our test startup script solved the issue:
import { expect } from 'chai';
global.expect = expect;
Trying to use the new inline syntax like this:
results in the following error when running the test:
Running the test using the older syntax works fine:
Using mocha + bdd-lazy-var. Any thoughts?