From 49f34ec477c8ac70dc3487bc51ebe84d15019b47 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Tue, 4 Jun 2024 14:35:28 +0200 Subject: [PATCH] feat!: rename indexScripts to orchestratorScripts (#5842) --- docs/config/index.md | 4 ++-- packages/browser/src/node/index.ts | 8 ++++---- packages/vitest/src/node/cli/cli-config.ts | 2 +- packages/vitest/src/node/workspace.ts | 2 +- packages/vitest/src/types/browser.ts | 2 +- test/browser/vitest.config.mts | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/config/index.md b/docs/config/index.md index 7b42d09f80a1..afcaa6474c79 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -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: diff --git a/packages/browser/src/node/index.ts b/packages/browser/src/node/index.ts index a32534284d3d..96218c246053 100644 --- a/packages/browser/src/node/index.ts +++ b/packages/browser/src/node/index.ts @@ -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) @@ -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 @@ -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') diff --git a/packages/vitest/src/node/cli/cli-config.ts b/packages/vitest/src/node/cli/cli-config.ts index 4e3ce7a73bd5..f858ea1ecab3 100644 --- a/packages/vitest/src/node/cli/cli-config.ts +++ b/packages/vitest/src/node/cli/cli-config.ts @@ -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, diff --git a/packages/vitest/src/node/workspace.ts b/packages/vitest/src/node/workspace.ts index bc7fe45e1e62..2c203a572e6c 100644 --- a/packages/vitest/src/node/workspace.ts +++ b/packages/vitest/src/node/workspace.ts @@ -393,7 +393,7 @@ export class WorkspaceProject { }, browser: { ...this.ctx.config.browser, - indexScripts: [], + orchestratorScripts: [], testerScripts: [], commands: {}, }, diff --git a/packages/vitest/src/types/browser.ts b/packages/vitest/src/types/browser.ts index 10ba97d9165c..7b7f58d74095 100644 --- a/packages/vitest/src/types/browser.ts +++ b/packages/vitest/src/types/browser.ts @@ -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 diff --git a/test/browser/vitest.config.mts b/test/browser/vitest.config.mts index a613cda53098..813dcfcb24f0 100644 --- a/test/browser/vitest.config.mts +++ b/test/browser/vitest.config.mts @@ -55,7 +55,7 @@ export default defineConfig({ src: '@vitest/injected-lib', }, ], - indexScripts: [ + orchestratorScripts: [ { content: 'console.log("Hello, World");globalThis.__injected = []', type: 'text/javascript',