jest/no-restricted-matchers Style
其作用
禁止使用特定的匹配器和修饰符,并可以建议替代方案。
示例
javascript
it("is false", () => {
// if this has a modifier (i.e. `not.toBeFalsy`), it would be considered fine
expect(a).toBeFalsy();
});
it("resolves", async () => {
// all uses of this modifier are disallowed, regardless of matcher
await expect(myPromise()).resolves.toBe(true);
});
describe("when an error happens", () => {
it("does not upload the file", async () => {
// all uses of this matcher are disallowed
expect(uploadFileMock).not.toHaveBeenCalledWith("file.name");
});
});