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

test: replace `resolve.alias/customResolver` with plugin `resolveId` (#9598)

authored by

Hiroshi Ogawa and committed by
GitHub
(Feb 6, 2026, 9:54 AM +0100) 1c4566e6 615fd521

+23 -21
+9 -9
test/snapshots/test/inline-multiple-calls.test.ts
··· 468 468 Received: "3" 469 469 470 470 ❯ each.test.ts:4:22 471 - 2| 471 + 2| 472 472 3| test.for(["hey", "world"])("test %s", (arg) => { 473 473 4| expect(arg.length).toMatchInlineSnapshot(\`5\`); 474 474 | ^ 475 475 5| }); 476 - 6| 476 + 6| 477 477 478 478 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/6]⎯ 479 479 ··· 484 484 Received: "5" 485 485 486 486 ❯ each.test.ts:4:22 487 - 2| 487 + 2| 488 488 3| test.for(["hey", "world"])("test %s", (arg) => { 489 489 4| expect(arg.length).toMatchInlineSnapshot(\`5\`); 490 490 | ^ 491 491 5| }); 492 - 6| 492 + 6| 493 493 494 494 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/6]⎯ 495 495 ··· 537 537 16| }).toThrowErrorMatchingInlineSnapshot(\`[Error: length = 5]\`) 538 538 | ^ 539 539 17| }); 540 - 18| 540 + 18| 541 541 542 542 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[5/6]⎯ 543 543 ··· 553 553 16| }).toThrowErrorMatchingInlineSnapshot(\`[Error: length = 5]\`) 554 554 | ^ 555 555 17| }); 556 - 18| 556 + 18| 557 557 558 558 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[6/6]⎯ 559 559 ··· 619 619 Received: "5" 620 620 621 621 ❯ each.test.ts:4:22 622 - 2| 622 + 2| 623 623 3| test.for(["hey", "world"])("test %s", (arg) => { 624 624 4| expect(arg.length).toMatchInlineSnapshot(\`5\`); 625 625 | ^ 626 626 5| }); 627 - 6| 627 + 6| 628 628 629 629 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/3]⎯ 630 630 ··· 656 656 16| }).toThrowErrorMatchingInlineSnapshot(\`[Error: length = 5]\`) 657 657 | ^ 658 658 17| }); 659 - 18| 659 + 18| 660 660 661 661 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[3/3]⎯ 662 662
+14 -12
test/coverage-test/fixtures/configs/vitest.config.conditional.ts
··· 2 2 import { defineConfig } from 'vitest/config' 3 3 4 4 export default defineConfig({ 5 - resolve: { 6 - alias: [ 7 - { 8 - find: /fixtures\/src\/conditional/, 9 - replacement: "$1", 10 - customResolver(_, __, options) { 11 - if ('ssr' in options && options.ssr) { 12 - return { id: resolve('fixtures/src/conditional/ssr.ts') } 5 + plugins: [ 6 + { 7 + name: 'test-resolve-conditional', 8 + resolveId: { 9 + order: 'pre', 10 + handler(source) { 11 + if (source.includes("fixtures/src/conditional")) { 12 + if (this.environment.config.consumer === 'server') { 13 + return resolve('fixtures/src/conditional/ssr.ts') 14 + } 15 + return resolve('fixtures/src/conditional/web.ts') 13 16 } 14 - return { id: resolve('fixtures/src/conditional/web.ts') } 15 - }, 17 + } 16 18 }, 17 - ], 18 - }, 19 + } 20 + ] 19 21 })