Skip to content

Update assertion-arguments rule to handle formatAsCodeBlock snapshot argument#361

Closed
novemberborn wants to merge 2 commits into
mainfrom
string-snapshots-as-codeblocks
Closed

Update assertion-arguments rule to handle formatAsCodeBlock snapshot argument#361
novemberborn wants to merge 2 commits into
mainfrom
string-snapshots-as-codeblocks

Conversation

@novemberborn

Copy link
Copy Markdown
Member

@novemberborn
novemberborn requested a review from sindresorhus May 15, 2026 19:03
@sindresorhus

Copy link
Copy Markdown
Member

This seeems to regress existing t.snapshot() message handling. The new logic treats any second argument that does not look syntactically like a string as the options object, so message variables are misread as options.

I manually checked these on the PR branch:

  • {message: 'always'} reports missing-message for const message = 'ok'; t.snapshot(value, message);
  • {message: 'never'} reports nothing for the same cal
  • t.snapshot(value, true) and t.snapshot(value, {formatAsCodeBlock: true}, true) also report nothing

could this detect the options form more narrowly, then run the existing message validation on the real message slot? This probaly needs tests for variable messages and non-string messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants