Skip to content

Commit efaf109

Browse files
authoredDec 13, 2023
fix(vitest/require-local-test-context-for-concurrent-snapshots): report for all types of snapshot tests (#322)
1 parent d71c88c commit efaf109

2 files changed

+17
-2
lines changed
 

‎src/rules/require-local-test-context-for-concurrent-snapshots.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ export default createEslintRule({
2626

2727
const isNotASnapshotAssertion = ![
2828
'toMatchSnapshot',
29-
'toMatchInlineSnapshot'
29+
'toMatchInlineSnapshot',
30+
'toMatchFileSnapshot',
31+
'toThrowErrorMatchingSnapshot',
32+
'toThrowErrorMatchingInlineSnapshot'
3033
].includes(node.callee.property.name)
3134

3235
if (isNotASnapshotAssertion) return

‎tests/require-local-test-context-for-concurrent-snapshots.test.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ ruleTester.run(RULE_NAME, rule, {
5353
expect(true).toMatchSnapshot();
5454
})`,
5555
errors: [{ messageId: 'requireLocalTestContext' }]
56-
}
56+
},
57+
{
58+
code: 'it.concurrent("should fail", () => { expect(true).toMatchFileSnapshot("./test/basic.output.html") })',
59+
errors: [{ messageId: 'requireLocalTestContext' }]
60+
},
61+
{
62+
code: 'it.concurrent("should fail", () => { expect(foo()).toThrowErrorMatchingSnapshot() })',
63+
errors: [{ messageId: 'requireLocalTestContext' }]
64+
},
65+
{
66+
code: 'it.concurrent("should fail", () => { expect(foo()).toThrowErrorMatchingInlineSnapshot("bar") })',
67+
errors: [{ messageId: 'requireLocalTestContext' }]
68+
},
5769
]
5870
})

0 commit comments

Comments
 (0)
Please sign in to comment.