diff --git a/packages/vite/src/resolver.ts b/packages/vite/src/resolver.ts index 002e9d5930..e7ea01ece9 100644 --- a/packages/vite/src/resolver.ts +++ b/packages/vite/src/resolver.ts @@ -41,6 +41,18 @@ export function resolver(): Plugin { } } }); + return () => { + server.middlewares.use((req, res, next) => { + if (req.originalUrl && req.originalUrl.length > 1) { + if (req.originalUrl?.match(/\/tests($|\?)/)) { + req.originalUrl = '/tests/index.html'; + (req as any).url = '/tests/index.html'; + return next(); + } + } + return next(); + }); + }; }, async resolveId(source, importer, options) { diff --git a/tests/scenarios/vite-internals-test.ts b/tests/scenarios/vite-internals-test.ts index e95d63c199..a80ed0995b 100644 --- a/tests/scenarios/vite-internals-test.ts +++ b/tests/scenarios/vite-internals-test.ts @@ -25,7 +25,7 @@ function buildViteInternalsTest(testNonColocatedTemplates: boolean, app: Project 'use strict'; module.exports = { - test_page: 'tests/index.html?hidepassed', + test_page: 'tests?hidepassed', disable_watching: true, launch_in_ci: ['Chrome'], launch_in_dev: ['Chrome'],