Skip to content

Commit

Permalink
fix tests url
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx committed Dec 4, 2024
1 parent 35f48d4 commit 0192c27
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions packages/vite/src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion tests/scenarios/vite-internals-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down

0 comments on commit 0192c27

Please sign in to comment.