【发布时间】:2020-06-04 07:46:45
【问题描述】:
这个微不足道的类只是一个例子......
class SomeClass{
getTemplateName() {
throw new Error('foo');
}
}
...尝试测试某些代码是否抛出异常
describe('dome class', () => {
test('contains a method that will throw an exception', () => {
var sc = new SomeClass();
expect(sc.getTemplateName()).toThrow(new Error('foo'));
});
});
但不工作。我做错了什么?
【问题讨论】: