Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1d8ebf9

Browse filesBrowse files
authored
feat(browser): use base url instead of __vitest__ (#8126)
1 parent dfe81a6 commit 1d8ebf9
Copy full SHA for 1d8ebf9

File tree

Expand file treeCollapse file tree

7 files changed

+10
-9
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+10
-9
lines changed

‎packages/browser/src/client/orchestrator.ts

Copy file name to clipboardExpand all lines: packages/browser/src/client/orchestrator.ts
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { relative } from 'pathe'
66
import { getUiAPI } from './ui'
77
import { getBrowserState, getConfig } from './utils'
88

9-
const url = new URL(location.href)
109
const ID_ALL = '__vitest_all__'
1110

1211
export class IframeOrchestrator {
@@ -187,7 +186,7 @@ export class IframeOrchestrator {
187186

188187
private createTestIframe(iframeId: string) {
189188
const iframe = document.createElement('iframe')
190-
const src = `${url.pathname}__vitest_test__/__test__/?sessionId=${getBrowserState().sessionId}&iframeId=${iframeId}`
189+
const src = `/?sessionId=${getBrowserState().sessionId}&iframeId=${iframeId}`
191190
iframe.setAttribute('loading', 'eager')
192191
iframe.setAttribute('src', src)
193192
iframe.setAttribute('data-vitest', 'true')

‎packages/browser/src/node/middlewares/orchestratorMiddleware.ts

Copy file name to clipboardExpand all lines: packages/browser/src/node/middlewares/orchestratorMiddleware.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function createOrchestratorMiddleware(parentServer: ParentBrowserProject)
99
return next()
1010
}
1111
const url = new URL(req.url, 'http://localhost')
12-
if (url.pathname !== parentServer.base) {
12+
if (url.pathname !== parentServer.prefixOrchestratorUrl) {
1313
return next()
1414
}
1515

‎packages/browser/src/node/middlewares/testerMiddleware.ts

Copy file name to clipboardExpand all lines: packages/browser/src/node/middlewares/testerMiddleware.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function createTesterMiddleware(browserServer: ParentBrowserProject): Con
99
return next()
1010
}
1111
const url = new URL(req.url, 'http://localhost')
12-
if (!url.pathname.startsWith(browserServer.prefixTesterUrl) || !url.searchParams.has('sessionId')) {
12+
if (url.pathname !== browserServer.prefixTesterUrl || !url.searchParams.has('sessionId')) {
1313
return next()
1414
}
1515

‎packages/browser/src/node/pool.ts

Copy file name to clipboardExpand all lines: packages/browser/src/node/pool.ts
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,10 @@ class BrowserPool {
248248
this.project,
249249
this,
250250
)
251-
const url = new URL('/', this.options.origin)
251+
const browser = this.project.browser!
252+
const url = new URL('/__vitest_test__/', this.options.origin)
252253
url.searchParams.set('sessionId', sessionId)
253-
const pagePromise = this.project.browser!.provider.openPage(
254+
const pagePromise = browser.provider.openPage(
254255
sessionId,
255256
url.toString(),
256257
)

‎packages/browser/src/node/projectParent.ts

Copy file name to clipboardExpand all lines: packages/browser/src/node/projectParent.ts
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class ParentBrowserProject {
2626
public testerScripts: HtmlTagDescriptor[] | undefined
2727

2828
public faviconUrl: string
29+
public prefixOrchestratorUrl: string
2930
public prefixTesterUrl: string
3031
public manifest: Promise<Vite.Manifest> | Vite.Manifest
3132

@@ -108,7 +109,8 @@ export class ParentBrowserProject {
108109
this.commands[command] = project.config.browser.commands[command]
109110
}
110111

111-
this.prefixTesterUrl = `${base}__vitest_test__/__test__/`
112+
this.prefixTesterUrl = `${base || '/'}`
113+
this.prefixOrchestratorUrl = `${base}__vitest_test__/`
112114
this.faviconUrl = `${base}__vitest__/favicon.svg`
113115

114116
this.manifest = (async () => {

‎packages/vitest/src/node/logger.ts

Copy file name to clipboardExpand all lines: packages/vitest/src/node/logger.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export class Logger {
252252
const providerString = provider === 'preview' ? '' : ` by ${c.reset(c.bold(provider))}`
253253
this.log(
254254
c.dim(
255-
`${output}Browser runner started${providerString} ${c.dim('at')} ${c.blue(new URL('/', origin))}\n`,
255+
`${output}Browser runner started${providerString} ${c.dim('at')} ${c.blue(new URL('/__vitest_test__/', origin))}\n`,
256256
),
257257
)
258258
}

‎test/browser/fixtures/mocking-out-of-root/project1/vitest.config.ts

Copy file name to clipboardExpand all lines: test/browser/fixtures/mocking-out-of-root/project1/vitest.config.ts
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export default defineConfig({
1414
screenshotFailures: false,
1515
headless: true,
1616
instances,
17-
headless: true,
1817
},
1918
},
2019
})

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.