跳至内容

jest/prefer-called-with 样式

作用

建议使用 toBeCalledWith()toHaveBeenCalledWith()

示例

javascript
// valid
expect(noArgsFunction).toBeCalledWith();
expect(roughArgsFunction).toBeCalledWith(expect.anything(), expect.any(Date));
expect(anyArgsFunction).toBeCalledTimes(1);
expect(uncalledFunction).not.toBeCalled();

// invalid
expect(someFunction).toBeCalled();
expect(someFunction).toHaveBeenCalled();

参考

在 MIT 许可证下发布。