Tôi đang cố gắng sử dụng expect thử nghiệm với mocha, viết bằng ES6, và đang nhận được TypeError
ngay cả với một trường hợp thử nghiệm đơn giản:Thử nghiệm Mocha ES6 được hỗ trợ?
import expect from "expect";
describe('Example',() => {
it('should just work', (done) => {
expect(5).to.eql(5);
done();
});
});
Tôi đang sử dụng Babel để chuyển đổi và chạy thử nghiệm:
./node_modules/.bin/mocha --compilers js:babel/register example.js
mà kết quả trong:
Example
1) should just work
0 passing (76ms)
1 failing
1) Example should just work:
TypeError: Cannot read property 'eql' of undefined
at Context.<anonymous> (example.js:5:17)
Điều này không được hỗ trợ hay tôi thiếu một số thứ quan trọng?
phiên bản:
- babel 5.5.6
- mong đợi 1.6.0
- mocha 2.2.5
Lưu ý rằng trong 'babel 6.x' bạn nên viết '--compilers js: babel-core/register'. –