Skip to content

Commit

Permalink
feat!: rename indexScripts to orchestratorScripts (#5842)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jun 4, 2024
1 parent caaafd9 commit 49f34ec
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1616,12 +1616,12 @@ Should Vitest UI be injected into the page. By default, injects UI iframe during
Default iframe's viewport.
#### browser.indexScripts {#browser-indexscripts}
#### browser.orchestratorScripts {#browser-orchestratorscripts}
- **Type:** `BrowserScript[]`
- **Default:** `[]`
Custom scripts that should be injected into the index HTML before test iframes are initiated. This HTML document only sets up iframes and doesn't actually import your code.
Custom scripts that should be injected into the orchestrator HTML before test iframes are initiated. This HTML document only sets up iframes and doesn't actually import your code.
The script `src` and `content` will be processed by Vite plugins. Script should be provided in the following shape:
Expand Down
8 changes: 4 additions & 4 deletions packages/browser/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default (project: WorkspaceProject, base = '/'): Plugin[] => {
}
next()
})
let indexScripts: string | undefined
let orchestratorScripts: string | undefined
let testerScripts: string | undefined
server.middlewares.use(async (req, res, next) => {
if (!req.url)
Expand Down Expand Up @@ -81,8 +81,8 @@ export default (project: WorkspaceProject, base = '/'): Plugin[] => {
// disable CSP for the orchestrator as we are the ones controlling it
res.removeHeader('Content-Security-Policy')

if (!indexScripts)
indexScripts = await formatScripts(project.config.browser.indexScripts, server)
if (!orchestratorScripts)
orchestratorScripts = await formatScripts(project.config.browser.orchestratorScripts, server)

let baseHtml = await orchestratorHtml

Expand All @@ -103,7 +103,7 @@ export default (project: WorkspaceProject, base = '/'): Plugin[] => {
const html = replacer(baseHtml, {
__VITEST_FAVICON__: favicon,
__VITEST_TITLE__: 'Vitest Browser Runner',
__VITEST_SCRIPTS__: indexScripts,
__VITEST_SCRIPTS__: orchestratorScripts,
__VITEST_INJECTOR__: injector,
})
res.write(html, 'utf-8')
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/cli/cli-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export const cliOptionsConfig: VitestCLIOptions = {
ui: {
description: 'Show Vitest UI when running tests (default: `!process.env.CI`)',
},
indexScripts: null,
orchestratorScripts: null,
testerScripts: null,
commands: null,
viewport: null,
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ export class WorkspaceProject {
},
browser: {
...this.ctx.config.browser,
indexScripts: [],
orchestratorScripts: [],
testerScripts: [],
commands: {},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/types/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export interface BrowserConfigOptions {
/**
* Scripts injected into the main window.
*/
indexScripts?: BrowserScript[]
orchestratorScripts?: BrowserScript[]

/**
* Commands that will be executed on the server
Expand Down
2 changes: 1 addition & 1 deletion test/browser/vitest.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default defineConfig({
src: '@vitest/injected-lib',
},
],
indexScripts: [
orchestratorScripts: [
{
content: 'console.log("Hello, World");globalThis.__injected = []',
type: 'text/javascript',
Expand Down

0 comments on commit 49f34ec

Please sign in to comment.