【发布时间】:2017-10-31 10:01:06
【问题描述】:
为什么我在运行这个测试文件时得到TypeError: expect is not a function?
我已经在本地安装了 mocha 和 chai,并通过 yarn run test 运行测试,它只运行 "test": "mocha"。
var chai = require('chai')
var expect = chai.expect()
describe('Array', function () {
describe('#indexOf()', function () {
it('should return -1 when the value is not present', function () {
expect([1, 2, 3].indexOf(4)).to.be.equal(-1)
})
})
})
【问题讨论】:
标签: javascript unit-testing mocha.js chai