Skip to content

Latest commit

 

History

History
26 lines (17 loc) · 640 Bytes

no-interpolation-in-snapshots.md

File metadata and controls

26 lines (17 loc) · 640 Bytes

Disallow string interpolation in snapshots (vitest/no-interpolation-in-snapshots)

⚠️ This rule warns in the 🌐 all config.

🔧 This rule is automatically fixable by the --fix CLI option.

Rule Details

This rule aims to prevent the use of string interpolation in snapshots.

Fail

expect('foo').toMatchSnapshot(`${bar}`)
expect('foo').toMatchSnapshot(`foo ${bar}`)

Pass

expect('foo').toMatchSnapshot()
expect('foo').toMatchSnapshot('foo')
expect('foo').toMatchSnapshot(bar)