[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.

fix(docs): fix old `/config/#option` hash links causing hydration errors (#9610)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>

authored by

Hiroshi Ogawa
Claude Opus 4.6
Vladimir
and committed by
GitHub
(Feb 10, 2026, 9:14 AM +0900) a603c3a3 24603e3c

+43 -34
+1 -1
packages/browser/context.d.ts
··· 514 514 */ 515 515 getByTitle: (text: string | RegExp, options?: LocatorOptions) => Locator 516 516 /** 517 - * Creates a locator capable of finding an element that matches the specified test id attribute. You can configure the attribute name with [`browser.locators.testIdAttribute`](/config/#browser-locators-testidattribute). 517 + * Creates a locator capable of finding an element that matches the specified test id attribute. You can configure the attribute name with [`browser.locators.testIdAttribute`](/config/browser/locators#browser-locators-testidattribute). 518 518 * @see {@link https://vitest.dev/api/browser/locators#getbytestid} 519 519 */ 520 520 getByTestId: (text: string | RegExp) => Locator
+33 -24
docs/.vitepress/theme/index.ts
··· 14 14 import 'virtual:group-icons.css' 15 15 16 16 if (inBrowser) { 17 + // redirect old hash links (e.g. /config/#reporters -> /config/reporters) 18 + // before hydration to avoid SSG hydration mismatch 19 + const redirect = getRedirectPath(new URL(location.href)) 20 + if (redirect) { 21 + location.replace(redirect) 22 + } 17 23 import('./pwa') 24 + } 25 + 26 + function getRedirectPath(url: URL) { 27 + if (url.pathname === '/api/' || url.pathname === '/api' || url.pathname === '/api/index.html') { 28 + return '/api/test' 29 + } 30 + if (!url.hash) { 31 + return 32 + } 33 + 34 + // /config/#reporters -> /config/reporters 35 + // /config/#coverage-provider -> /config/coverage#coverage-provider 36 + // /config/#browser.enabled -> /config/browser/enabled 37 + if (url.pathname === '/config' || url.pathname === '/config/' || url.pathname === '/config.html') { 38 + if (url.hash.startsWith('#browser.')) { 39 + const [page, ...hash] = url.hash.slice('#browser.'.length).toLowerCase().split('-') 40 + return `/config/browser/${page}${hash.length ? `#${[page, ...hash].join('-')}` : ''}` 41 + } 42 + const [page, ...hash] = url.hash.slice(1).toLowerCase().split('-') 43 + return `/config/${page}${hash.length ? `#${[page, ...hash].join('-')}` : ''}` 44 + } 45 + // /guide/browser/config#browser.locators-testidattribute -> /config/browser/locators#browser-locators-testidattribute 46 + if (url.pathname === '/guide/browser/config' || url.pathname === '/guide/browser/config/' || url.pathname === '/guide/browser/config.html') { 47 + const [page, ...hash] = url.hash.slice('#browser.'.length).toLowerCase().split('-') 48 + return `/config/browser/${page}${hash.length ? `#${[page, ...hash].join('-')}` : ''}` 49 + } 18 50 } 19 51 20 52 export default { 21 53 extends: VitestTheme as unknown as any, 22 - enhanceApp({ app, router }) { 23 - router.onBeforeRouteChange = (to) => { 24 - if (typeof location === 'undefined') { 25 - return true 26 - } 27 - const url = new URL(to, location.href) 28 - if (url.pathname === '/api/' || url.pathname === '/api' || url.pathname === '/api/index.html') { 29 - setTimeout(() => { router.go(`/api/test`) }) 30 - return false 31 - } 32 - if (!url.hash) { 33 - return true 34 - } 35 - if (url.pathname === '/config' || url.pathname === '/config/' || url.pathname === '/config.html') { 36 - const [page, ...hash] = (url.hash.startsWith('#browser.') ? url.hash.slice(9) : url.hash.slice(1)).toLowerCase().split('-') 37 - setTimeout(() => { router.go(`/config/${page}${hash.length ? `#${[page, ...hash].join('-')}` : ''}`) }) 38 - return false 39 - } 40 - if (url.pathname === '/guide/browser/config' || url.pathname === '/guide/browser/config/' || url.pathname === '/guide/browser/config.html') { 41 - const [page, ...hash] = url.hash.slice('#browser.'.length).toLowerCase().split('-') 42 - setTimeout(() => { router.go(`/config/browser/${page}${hash.length ? `#${[page, ...hash].join('-')}` : ''}`) }) 43 - return false 44 - } 45 - } 54 + enhanceApp({ app }) { 46 55 app.component('Version', Version) 47 56 app.component('CRoot', CRoot) 48 57 app.component('Experimental', Experimental)
+2 -2
packages/spy/src/types.ts
··· 224 224 /** 225 225 * Clears all information about every call. After calling it, all properties on `.mock` will return to their initial state. This method does not reset implementations. It is useful for cleaning up mocks between different assertions. 226 226 * 227 - * To automatically call this method before each test, enable the [`clearMocks`](https://vitest.dev/config/#clearmocks) setting in the configuration. 227 + * To automatically call this method before each test, enable the [`clearMocks`](https://vitest.dev/config/clearmocks) setting in the configuration. 228 228 * @see https://vitest.dev/api/mock#mockclear 229 229 */ 230 230 mockClear(): this ··· 234 234 * Note that resetting a mock from `vi.fn()` will set implementation to an empty function that returns `undefined`. 235 235 * Resetting a mock from `vi.fn(impl)` will set implementation to `impl`. It is useful for completely resetting a mock to its default state. 236 236 * 237 - * To automatically call this method before each test, enable the [`mockReset`](https://vitest.dev/config/#mockreset) setting in the configuration. 237 + * To automatically call this method before each test, enable the [`mockReset`](https://vitest.dev/config/mockreset) setting in the configuration. 238 238 * @see https://vitest.dev/api/mock#mockreset 239 239 */ 240 240 mockReset(): this
+2 -2
packages/vitest/src/integrations/vi.ts
··· 43 43 runOnlyPendingTimersAsync: () => Promise<VitestUtils> 44 44 /** 45 45 * This method will invoke every initiated timer until the timer queue is empty. It means that every timer called during `runAllTimers` will be fired. 46 - * If you have an infinite interval, it will throw after 10,000 tries (can be configured with [`fakeTimers.loopLimit`](https://vitest.dev/config/#faketimers-looplimit)). 46 + * If you have an infinite interval, it will throw after 10,000 tries (can be configured with [`fakeTimers.loopLimit`](https://vitest.dev/config/faketimers#faketimers-looplimit)). 47 47 */ 48 48 runAllTimers: () => VitestUtils 49 49 /** 50 50 * This method will asynchronously invoke every initiated timer until the timer queue is empty. It means that every timer called during `runAllTimersAsync` will be fired even asynchronous timers. 51 - * If you have an infinite interval, it will throw after 10 000 tries (can be configured with [`fakeTimers.loopLimit`](https://vitest.dev/config/#faketimers-looplimit)). 51 + * If you have an infinite interval, it will throw after 10 000 tries (can be configured with [`fakeTimers.loopLimit`](https://vitest.dev/config/faketimers#faketimers-looplimit)). 52 52 */ 53 53 runAllTimersAsync: () => Promise<VitestUtils> 54 54 /**
+1 -1
packages/vitest/src/node/core.ts
··· 1453 1453 } 1454 1454 1455 1455 if (!this.reporters.some(r => r instanceof HangingProcessReporter)) { 1456 - console.warn('You can try to identify the cause by enabling "hanging-process" reporter. See https://vitest.dev/config/#reporters') 1456 + console.warn('You can try to identify the cause by enabling "hanging-process" reporter. See https://vitest.dev/config/reporters') 1457 1457 } 1458 1458 } 1459 1459
+4 -4
packages/vitest/src/node/types/browser.ts
··· 288 288 /** 289 289 * Enables tracking uncaught errors and exceptions so they can be reported by Vitest. 290 290 * 291 - * If you need to hide certain errors, it is recommended to use [`onUnhandledError`](https://vitest.dev/config/#onunhandlederror) option instead. 291 + * If you need to hide certain errors, it is recommended to use [`onUnhandledError`](https://vitest.dev/config/onunhandlederror) option instead. 292 292 * 293 293 * Disabling this will completely remove all Vitest error handlers, which can help debugging with the "Pause on exceptions" checkbox turned on. 294 294 * @default true ··· 455 455 screenshotDirectory: string 456 456 /** 457 457 * Absolute path to the project's 458 - * {@linkcode https://vitest.dev/config/#root|root}. 458 + * {@linkcode https://vitest.dev/config/root|root}. 459 459 */ 460 460 root: string 461 461 /** 462 462 * Path to the test file, relative to the project's 463 - * {@linkcode https://vitest.dev/config/#root|root}. 463 + * {@linkcode https://vitest.dev/config/root|root}. 464 464 */ 465 465 testFileDirectory: string 466 466 /** ··· 474 474 testName: string 475 475 /** 476 476 * The value provided to 477 - * {@linkcode https://vitest.dev/config/#attachmentsdir|attachmentsDir}, 477 + * {@linkcode https://vitest.dev/config/attachmentsdir|attachmentsDir}, 478 478 * if none is provided, its default value. 479 479 */ 480 480 attachmentsDir: string