Skip to content

Commit

Permalink
fix(vitest/require-local-test-context-for-concurrent-snapshots): repo…
Browse files Browse the repository at this point in the history
…rt for all types of snapshot tests (#322)
  • Loading branch information
Haberkamp committed Dec 13, 2023
1 parent d71c88c commit efaf109
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Expand Up @@ -26,7 +26,10 @@ export default createEslintRule({

const isNotASnapshotAssertion = ![
'toMatchSnapshot',
'toMatchInlineSnapshot'
'toMatchInlineSnapshot',
'toMatchFileSnapshot',
'toThrowErrorMatchingSnapshot',
'toThrowErrorMatchingInlineSnapshot'
].includes(node.callee.property.name)

if (isNotASnapshotAssertion) return
Expand Down
Expand Up @@ -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' }]
},
]
})

0 comments on commit efaf109

Please sign in to comment.