From 564c9dff7659f532d6fbef608c7651baee54ed90 Mon Sep 17 00:00:00 2001 From: Nils Haberkamp Date: Tue, 12 Dec 2023 10:46:07 +0000 Subject: [PATCH] fix(vitest/require-local-test-context-for-concurrent-snapshots): report for all types of snapshot tests --- ...-local-test-context-for-concurrent-snapshots.ts | 5 ++++- ...l-test-context-for-concurrent-snapshots.test.ts | 14 +++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/rules/require-local-test-context-for-concurrent-snapshots.ts b/src/rules/require-local-test-context-for-concurrent-snapshots.ts index 9b8768c..d548088 100644 --- a/src/rules/require-local-test-context-for-concurrent-snapshots.ts +++ b/src/rules/require-local-test-context-for-concurrent-snapshots.ts @@ -26,7 +26,10 @@ export default createEslintRule({ const isNotASnapshotAssertion = ![ 'toMatchSnapshot', - 'toMatchInlineSnapshot' + 'toMatchInlineSnapshot', + 'toMatchFileSnapshot', + 'toThrowErrorMatchingSnapshot', + 'toThrowErrorMatchingInlineSnapshot' ].includes(node.callee.property.name) if (isNotASnapshotAssertion) return diff --git a/tests/require-local-test-context-for-concurrent-snapshots.test.ts b/tests/require-local-test-context-for-concurrent-snapshots.test.ts index f9692d9..a8f3f56 100644 --- a/tests/require-local-test-context-for-concurrent-snapshots.test.ts +++ b/tests/require-local-test-context-for-concurrent-snapshots.test.ts @@ -53,6 +53,18 @@ ruleTester.run(RULE_NAME, rule, { expect(true).toMatchSnapshot(); })`, errors: [{ messageId: 'requireLocalTestContext' }] - } + }, + { + code: 'it.concurrent("should fail", () => { expect(true).toMatchFileSnapshot("./test/basic.output.html") })', + errors: [{ messageId: 'requireLocalTestContext' }] + }, + { + code: 'it.concurrent("should fail", () => { expect(foo()).toThrowErrorMatchingSnapshot() })', + errors: [{ messageId: 'requireLocalTestContext' }] + }, + { + code: 'it.concurrent("should fail", () => { expect(foo()).toThrowErrorMatchingInlineSnapshot("bar") })', + errors: [{ messageId: 'requireLocalTestContext' }] + }, ] })