From 0192c27a21bfb6b0ffb20b471258ceca6de801ef Mon Sep 17 00:00:00 2001 From: Patrick Pircher Date: Tue, 3 Dec 2024 00:08:11 +0100 Subject: [PATCH] fix tests url --- packages/vite/src/resolver.ts | 14 ++++++++++++++ tests/scenarios/vite-internals-test.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/resolver.ts b/packages/vite/src/resolver.ts index 002e9d593..59c90e2a7 100644 --- a/packages/vite/src/resolver.ts +++ b/packages/vite/src/resolver.ts @@ -41,6 +41,20 @@ export function resolver(): Plugin { } } }); + return () => { + server.middlewares.use((req, _res, next) => { + const base = server.config.base || '/'; + const originalUrl = req.originalUrl!.slice(base.length - 1); + if (originalUrl && originalUrl.length > 1) { + if (originalUrl?.match(/^\/tests($|\?)/)) { + req.originalUrl = `${base}tests/index.html`; + (req as any).url = `${base}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 e95d63c19..a80ed0995 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'],