jest/require-to-throw-message 正确性
做什么
如果 toThrow()
或 toThrowError()
在没有错误消息的情况下使用,此规则将触发警告。
示例
javascript
// invalid
test("all the things", async () => {
expect(() => a()).toThrow();
expect(() => a()).toThrowError();
await expect(a()).rejects.toThrow();
await expect(a()).rejects.toThrowError();
});
// valid
test("all the things", async () => {
expect(() => a()).toThrow("a");
expect(() => a()).toThrowError("a");
await expect(a()).rejects.toThrow("a");
await expect(a()).rejects.toThrowError("a");
});