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");
});