How To Make Sure 'this' Inside Mocha Test Have Access To Class Properties
const expect = require('chai').expect; class Test { constructor(){ this.x= 10;} run() { describe('test goes here', function() { it('sample test', function() { expect(this
Solution 1:
Use arrow functions () => this...
or .bind
on your functions.
describe("test goes here", () => {
it("sample test", () => {
expect(this.x).to.be.eq(10);
});
});
Post a Comment for "How To Make Sure 'this' Inside Mocha Test Have Access To Class Properties"