即使引发错误,此代码也会失败。
<div>
<div id="map" style="width: 600px; height: 400px"></div>
<div style="pointer-events: none; position: absolute; top: 100px; left: 100px">foo bar</div>
</div>
我也试过这个
it('should throw error when foo config value is falsey', (done) => {
const config = { foo: null, bar: 'some-name' };
expect(quux.withConfig(config).load('*', (err, inst) => { done(); })).toThrow();
});
错误讯息:
it('should throw error when foo config value is falsey', (done) => {
const config = { foo: null, bar: 'some-name' };
expect(SelfServiceCompletedJobStore.withConfig(config).load('*', (err, inst) => { })).toThrow();
done();
});
答案 0 :(得分:3)
你应该将一个函数传递给expect(...)。以下代码:
expect(quux.withConfig(config).load('*', (err, inst) => { done(); })).toThrow();
试图将调用的结果传递给expect(...),
改为使用匿名函数:
expect(function(){
quux.withConfig(config).load('*', (err, inst) => { done(); });
}).toThrow();