Support code block formatting for string snapshots
Open
enhancement
scope:assertions
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
As an overload in `SnapshotAssertion`: https://github.com/avajs/ava/blob/a6f42ea472cfbe7047a0fb89ab0cd728b4e04ae1/types/assertions.d.cts#L320-L332)
```ts
snapshot(expected: string, options?: { formatAsCodeBlock: true | string }, message?: string)
```
This options object should only be accepted for string values, and must only contain `formatAsCodeBlock`. `string` values would be the syntax, and `true` would be the same as an empty string (but less weird).
When formatting, backticks would need to be escaped properly.
_Originally posted by @novemberborn in https://github.com/avajs/ava/discussions/2903#discussioncomment-13017478_
Contributor guide
Assessment
This issue has not been assessed yet.