jest/no-confusing-set-timeout 스타일
작동 방식
jest.setTimeout의 혼란스러운 사용을 금지합니다.
왜 좋지 않은가?
- 전역 범위 이외의 위치에서 호출되는 경우
- 여러 번 호출되는 경우
- 후크,
describe,test, 또는it같은 다른 Jest 함수 이후에 호출되는 경우
예시
아래 모든 사례는 잘못된 사용입니다:
javascript
escribe("테스트 바", () => {
jest.setTimeout(1000);
it("테스트 설명", () => {
// 테스트 로직;
});
});
describe("테스트 바", () => {
it("테스트 설명", () => {
jest.setTimeout(1000);
// 테스트 로직;
});
});
test("foo-bar", () => {
jest.setTimeout(1000);
});
describe("단위 테스트", () => {
beforeEach(() => {
jest.setTimeout(1000);
});
});사용 방법
이 규칙을 설정 파일 또는 CLI를 통해 활성화하려면 다음을 사용할 수 있습니다:
json
{
"plugins": ["jest"],
"rules": {
"jest/no-confusing-set-timeout": "error"
}
}bash
oxlint --deny jest/no-confusing-set-timeout --jest-plugin