[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Kyℓe Hensel and committed by
GitHub
(Jul 21, 2026, 3:53 PM +0200) 15e0af95 75ed9ead

+38 -1
+1 -1
packages/vitest/src/runtime/runner/suite.ts
··· 1019 1019 1020 1020 const isObjectItem = isObject(items[0]) 1021 1021 function formatAttribute(s: string) { 1022 - return s.replace(/\$([$\w.]+)/g, (_, key: string) => { 1022 + return s.replace(/\$([$\p{ID_Continue}.]+)/gu, (_, key: string) => { 1023 1023 const isArrayKey = /^\d+$/.test(key) 1024 1024 if (!isObjectItem && !isArrayKey) { 1025 1025 return `$${key}`
+29
test/e2e/test/each-non-ascii-placeholders.test.ts
··· 1 + import { runInlineTests } from '#test-utils' 2 + import { expect, test } from 'vitest' 3 + 4 + test('formatting of non-ascii placeholders in test.each', async () => { 5 + const { stderr, ctx } = await runInlineTests({ 6 + 'basic.test.js': ` 7 + test.each\` 8 + 时间戳 | 结果 9 + \${1} | \${5} 10 + \${2} | \${10} 11 + \`('returns $结果 given $时间戳', ({ 结果, 时间戳 }) => { 12 + expect(结果).toBeGreaterThan(时间戳) 13 + }) 14 + `, 15 + 'vitest.config.js': { 16 + test: { 17 + globals: true, 18 + }, 19 + }, 20 + }) 21 + 22 + expect(stderr).toBe('') 23 + expect(ctx?.state.getTestModules()[0].children.array()).toStrictEqual( 24 + [ 25 + expect.objectContaining({ name: 'returns 5 given 1' }), 26 + expect.objectContaining({ name: 'returns 10 given 2' }), 27 + ], 28 + ) 29 + })
+8
test/unit/test/each.test.ts
··· 226 226 }) 227 227 228 228 test.each` 229 + ω | Σ 230 + ${1} | ${5} 231 + ${2} | ${10} 232 + `('returns true when $ω is < $Σ', ({ ω, Σ }) => { 233 + expect(Σ).toBeGreaterThan(ω) 234 + }) 235 + 236 + test.each` 229 237 a | b | expected 230 238 ${true} | ${true} | ${true} 231 239 `('($a && $b) -> $expected', ({ a, b, expected }) => {