jest/no-interpolation-in-snapshots 스타일
작동 방식
스냅샷 내에서 문자열 인터폴레이션을 사용하는 것을 방지합니다.
왜 좋지 않은가?
인터폴레이션은 스냅샷이 업데이트되지 않게 만듭니다. 대신, 속성 매처를 사용하여 속성을 오버로드해야 합니다.
예시
이 규칙에 위배되는 잘못된 코드 예시:
javascript
expect(something).toMatchInlineSnapshot(
`Object {
property: ${interpolated}
}`,
);
expect(something).toMatchInlineSnapshot(
{ other: expect.any(Number) },
`Object {
other: Any<Number>,
property: ${interpolated}
}`,
);
expect(errorThrowingFunction).toThrowErrorMatchingInlineSnapshot(`${interpolated}`);이 규칙은 eslint-plugin-vitest와 호환됩니다. 이를 사용하려면 다음 구성 정보를 .oxlintrc.json에 추가하세요:
json
{
"rules": {
"vitest/no-interpolation-in-snapshots": "error"
}
}사용 방법
구성 파일 또는 명령줄에서 이 규칙을 활성화하려면 다음과 같이 사용할 수 있습니다:
json
{
"plugins": ["jest"],
"rules": {
"jest/no-interpolation-in-snapshots": "error"
}
}bash
oxlint --deny jest/no-interpolation-in-snapshots --jest-plugin