7
摩卡/柴的Expect.to.throw不能捕获抛出的错误
我在让Chai的expect.to.thrownode.js应用程序进行测试时遇到问题。测试会因抛出的错误而不断失败,但是如果我将测试用例包装在try和catch中并断言所捕获的错误,它将起作用。 难道expect.to.throw不喜欢的工作,我认为它应该还是什么? it('should throw an error if you try to get an undefined property', function (done) { var params = { a: 'test', b: 'test', c: 'test' }; var model = new TestModel(MOCK_REQUEST, params); // neither of these work expect(model.get('z')).to.throw('Property does not exist in model schema.'); expect(model.get('z')).to.throw(new Error('Property does not …
257
javascript
node.js
mocha
chai