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 fe5969c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
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 test-packages/support/testem-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function testemProxy(targetURL: string) {
if (url === '/testem.js' || url.startsWith('/testem/')) {
return next();
}
let m = /^(\/\d+)\/tests\/index.html/.exec(url);
let m = /^(\/\d+)\/tests($|.)+/.exec(url);
if (m) {
url = url.slice(m[1].length);
}
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 fe5969c

Please sign in to comment.