Javascript 如何确保';这';在mocha测试中,您可以访问类属性
const expect=require(“chai”)。expect 获取x是未定义的 问题:此内部描述完成不同上下文的点,如何使x可用于此内部摩卡测试使用箭头函数Javascript 如何确保';这';在mocha测试中,您可以访问类属性,javascript,node.js,mocha.js,Javascript,Node.js,Mocha.js,const expect=require(“chai”)。expect 获取x是未定义的 问题:此内部描述完成不同上下文的点,如何使x可用于此内部摩卡测试使用箭头函数()=>此…或对函数进行绑定 describe("test goes here", () => { it("sample test", () => { expect(this.x).to.be.eq(10); }); }); 在函数上使用箭头函数()=>此…或.bind describe("test
()=>此…
或对函数进行绑定
describe("test goes here", () => {
it("sample test", () => {
expect(this.x).to.be.eq(10);
});
});
在函数上使用箭头函数()=>此…
或.bind
describe("test goes here", () => {
it("sample test", () => {
expect(this.x).to.be.eq(10);
});
});
感谢更新,只是好奇箭头函数和常规函数有何不同?@user522170感谢更新,只是好奇箭头函数和常规函数有何不同?@user522170