Skip to content

feat: support non-ascii characters in for/each title placeholders - #10773

Merged
sheremet-va merged 1 commit into
vitest-dev:mainfrom
k-yle:kh/no-ascii-variables
Jul 21, 2026
Merged

sheremet-va merged 1 commit into
vitest-dev:mainfrom
k-yle:kh/no-ascii-variables

Conversation

@k-yle

@k-yle k-yle commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Description

although it's unusual, it's theoretically possible to use non-ascii characters in variable names. For example:

// math-heavy code might use greek letters:
it.each`
  ω    | Σ
  ${1} | ${5}
  ${2} | ${10}
`('returns true when $ω is < $Σ', ({ ω, Σ }) => {
  // ...
});


// and I suppose this works in some other languages too:
it.each`
  时间戳 | 结果
  ${1}  | ${5}
  ${2}  | ${10}
`('returns $结果 given $时间戳', ({ 结果, 时间戳 }) => {
  // ...
});

currently, the test title formatter use RegEx \w, so it doesn't support non-ascii values. \p{ID_Continue} has been supported since node v10, see Unicode's UAX31-D1 for more info.

Before After
image image

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@netlify

netlify Bot commented Jul 14, 2026

Copy link
Copy Markdown

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 2a6e5fa
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6a576143f233dd00082b3869
😎 Deploy Preview https://deploy-preview-10773--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread test/unit/test/each.test.ts
@k-yle
k-yle force-pushed the kh/no-ascii-variables branch from e98ee9a to 2a6e5fa Compare July 15, 2026 10:30
@hi-ogawa hi-ogawa changed the title feat(it.each): support non-ascii characters in placeholders feat: support non-ascii characters in for/each title placeholders Jul 16, 2026

@hi-ogawa hi-ogawa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

I've let agents do some adversarial edge cases and it surfaced interesting case. Some looks technically breaking change-ish, but probably fine (we land this in next v5 anyways).

Placeholder Before: \w After: \p{ID_Continue}
$对象.结果 No match; remains literal row["对象"]["结果"]
$a.结果 Captures a.row.a[""] + "结果" row.a["结果"]
$𐐀 No match row["𐐀"]
No match row["é"]
$é Captures erow.e + "\u0301" row["e\u0301"]
$fooé Captures foorow.foo + "é" row["fooé"]
$a‌b Captures arow.a + "\u200Cb" row["a\u200Cb"]
$a·b Captures arow.a + "·b" row["a·b"]
$abc No match row["abc"]
$́foo No match row["\u0301foo"]
$foo-bar row.foo + "-bar" Unchanged
$💡 Remains literal Unchanged
$.foo row[""]["foo"] Unchanged
$foo..bar row.foo[""].bar Unchanged
$0 items[0] Unchanged

Also side note, it looks like people normally use it like [$_\p{ID_Start}][$\p{ID_Continue}]* to match javascript identifier-ish string, but in our case, we do want to match non identifier for array placeholder like 0 (in title $0), so just matching ID_Continue seems like a good choice.

@sheremet-va
sheremet-va merged commit 15e0af9 into vitest-dev:main Jul 21, 2026
26 of 27 checks passed
@k-yle
k-yle deleted the kh/no-ascii-variables branch July 21, 2026 14:02
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Sponsor
SponsoredKunjungi sekarang
Promo