From efaf10933cc3332840b12071950a4a4d191eeac4 Mon Sep 17 00:00:00 2001 From: Nils Haberkamp Date: Wed, 13 Dec 2023 17:08:14 +0100 Subject: [PATCH] fix(vitest/require-local-test-context-for-concurrent-snapshots): report for all types of snapshot tests (#322) --- ...-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' }] + }, ] })