Skip to content

jest/no-restricted-jest-methods Style ​

What it does ​

Restrict the use of specific jest and vi methods.

Example ​

javascript
jest.useFakeTimers();
it("calls the callback after 1 second via advanceTimersByTime", () => {
  // ...

  jest.advanceTimersByTime(1000);

  // ...
});

test("plays video", () => {
  const spy = jest.spyOn(video, "play");

  // ...
});

How to use ​

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny jest/no-restricted-jest-methods --jest-plugin
json
{
  "plugins": ["jest"],
  "rules": {
    "jest/no-restricted-jest-methods": "error"
  }
}

References ​

Released under the MIT License.