From 8c3601090ad0d5b5e54b81e5369101271651cfcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez?= Date: Sun, 20 Feb 2022 18:04:36 +0100 Subject: [PATCH 1/4] fix(ui/api): ui and api regression The ui and the api are not started --- packages/vitest/src/node/plugins/index.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/vitest/src/node/plugins/index.ts b/packages/vitest/src/node/plugins/index.ts index 7ecee6e57576..d0bd2bcdc638 100644 --- a/packages/vitest/src/node/plugins/index.ts +++ b/packages/vitest/src/node/plugins/index.ts @@ -104,6 +104,19 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest()) for (const name in envs) process.env[name] ??= envs[name] + + viteConfig.server.open = options.ui && options.open + ? options.uiBase ?? '/__vitest__/' + : undefined + + if (typeof options.api?.host === 'string') + viteConfig.server.host = options.api.host + + if (typeof options.api?.host === 'number') + viteConfig.server.port = options.api.port + + if (typeof options.api?.strictPort === 'number') + viteConfig.server.strictPort = options.api.strictPort }, async configureServer(server) { if (haveStarted) From 707eeddc29bd144b18628d2fa840a4718115fdd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez?= Date: Sun, 20 Feb 2022 18:06:12 +0100 Subject: [PATCH 2/4] chore: wrong entry for port if statement --- packages/vitest/src/node/plugins/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vitest/src/node/plugins/index.ts b/packages/vitest/src/node/plugins/index.ts index d0bd2bcdc638..240e7606e554 100644 --- a/packages/vitest/src/node/plugins/index.ts +++ b/packages/vitest/src/node/plugins/index.ts @@ -112,7 +112,7 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest()) if (typeof options.api?.host === 'string') viteConfig.server.host = options.api.host - if (typeof options.api?.host === 'number') + if (typeof options.api?.port === 'number') viteConfig.server.port = options.api.port if (typeof options.api?.strictPort === 'number') From 545f15a392c1a9ca646458faa89c07ca5421e634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez?= Date: Sun, 20 Feb 2022 18:11:17 +0100 Subject: [PATCH 3/4] chore: update server entries only if defined --- packages/vitest/src/node/plugins/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/vitest/src/node/plugins/index.ts b/packages/vitest/src/node/plugins/index.ts index 240e7606e554..b03e2ef7ef6e 100644 --- a/packages/vitest/src/node/plugins/index.ts +++ b/packages/vitest/src/node/plugins/index.ts @@ -106,16 +106,16 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest()) process.env[name] ??= envs[name] viteConfig.server.open = options.ui && options.open - ? options.uiBase ?? '/__vitest__/' + ? options.uiBase ?? configDefaults.uiBase : undefined - if (typeof options.api?.host === 'string') + if (typeof options.api?.host !== 'undefined') viteConfig.server.host = options.api.host - if (typeof options.api?.port === 'number') + if (typeof options.api?.port !== 'undefined') viteConfig.server.port = options.api.port - if (typeof options.api?.strictPort === 'number') + if (typeof options.api?.strictPort === 'boolean') viteConfig.server.strictPort = options.api.strictPort }, async configureServer(server) { From 580a1b404402f28ac4ada53ba665707232a513ab Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Mon, 21 Feb 2022 13:54:03 +0800 Subject: [PATCH 4/4] chore: update --- packages/ui/client/auto-imports.d.ts | 4 ++++ packages/vitest/src/node/plugins/index.ts | 17 ++--------------- packages/vitest/src/node/reporters/base.ts | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/packages/ui/client/auto-imports.d.ts b/packages/ui/client/auto-imports.d.ts index 83ff089481bc..ec199e95faf0 100644 --- a/packages/ui/client/auto-imports.d.ts +++ b/packages/ui/client/auto-imports.d.ts @@ -42,6 +42,7 @@ declare global { const onDeactivated: typeof import('vue')['onDeactivated'] const onErrorCaptured: typeof import('vue')['onErrorCaptured'] const onKeyStroke: typeof import('@vueuse/core')['onKeyStroke'] + const onLongPress: typeof import('@vueuse/core')['onLongPress'] const onMounted: typeof import('vue')['onMounted'] const onRenderTracked: typeof import('vue')['onRenderTracked'] const onRenderTriggered: typeof import('vue')['onRenderTriggered'] @@ -88,6 +89,7 @@ declare global { const useBreakpoints: typeof import('@vueuse/core')['useBreakpoints'] const useBroadcastChannel: typeof import('@vueuse/core')['useBroadcastChannel'] const useBrowserLocation: typeof import('@vueuse/core')['useBrowserLocation'] + const useCached: typeof import('@vueuse/core')['useCached'] const useClamp: typeof import('@vueuse/core')['useClamp'] const useClipboard: typeof import('@vueuse/core')['useClipboard'] const useColorMode: typeof import('@vueuse/core')['useColorMode'] @@ -125,6 +127,7 @@ declare global { const useFullscreen: typeof import('@vueuse/core')['useFullscreen'] const useGeolocation: typeof import('@vueuse/core')['useGeolocation'] const useIdle: typeof import('@vueuse/core')['useIdle'] + const useInfiniteScroll: typeof import('@vueuse/core')['useInfiniteScroll'] const useIntersectionObserver: typeof import('@vueuse/core')['useIntersectionObserver'] const useInterval: typeof import('@vueuse/core')['useInterval'] const useIntervalFn: typeof import('@vueuse/core')['useIntervalFn'] @@ -145,6 +148,7 @@ declare global { const useNavigatorLanguage: typeof import('@vueuse/core')['useNavigatorLanguage'] const useNetwork: typeof import('@vueuse/core')['useNetwork'] const useNow: typeof import('@vueuse/core')['useNow'] + const useOffsetPagination: typeof import('@vueuse/core')['useOffsetPagination'] const useOnline: typeof import('@vueuse/core')['useOnline'] const usePageLeave: typeof import('@vueuse/core')['usePageLeave'] const useParallax: typeof import('@vueuse/core')['useParallax'] diff --git a/packages/vitest/src/node/plugins/index.ts b/packages/vitest/src/node/plugins/index.ts index b03e2ef7ef6e..b74ddb9279aa 100644 --- a/packages/vitest/src/node/plugins/index.ts +++ b/packages/vitest/src/node/plugins/index.ts @@ -24,7 +24,7 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest()) // preliminary merge of options to be able to create server options for vite // however to allow vitest plugins to modify vitest config values // this is repeated in configResolved where the config is final - const preOptions = deepMerge({}, options, viteConfig.test ?? {}) + const preOptions = deepMerge({}, configDefaults, options, viteConfig.test ?? {}) preOptions.api = resolveApiConfig(preOptions) // store defines for globalThis to make them @@ -104,26 +104,13 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest()) for (const name in envs) process.env[name] ??= envs[name] - - viteConfig.server.open = options.ui && options.open - ? options.uiBase ?? configDefaults.uiBase - : undefined - - if (typeof options.api?.host !== 'undefined') - viteConfig.server.host = options.api.host - - if (typeof options.api?.port !== 'undefined') - viteConfig.server.port = options.api.port - - if (typeof options.api?.strictPort === 'boolean') - viteConfig.server.strictPort = options.api.strictPort }, async configureServer(server) { if (haveStarted) await ctx.report('onServerRestart') await ctx.setServer(options, server) haveStarted = true - if (options.api) + if (options.api && options.watch) (await import('../../api/setup')).setup(ctx) // #415, in run mode we don't need the watcher, close it would improve the performance diff --git a/packages/vitest/src/node/reporters/base.ts b/packages/vitest/src/node/reporters/base.ts index a7f3d9e3d2a2..f427b7310afa 100644 --- a/packages/vitest/src/node/reporters/base.ts +++ b/packages/vitest/src/node/reporters/base.ts @@ -25,10 +25,20 @@ export abstract class BaseReporter implements Reporter { onInit(ctx: Vitest) { this.ctx = ctx + + this.ctx.log() + const mode = this.ctx.config.watch - ? c.blue(' WATCH ') + ? c.blue(' DEV ') : c.cyan(' RUN ') - this.ctx.log(`\n${c.inverse(c.bold(mode))} ${c.gray(this.ctx.config.root)}\n`) + this.ctx.log(`${c.inverse(c.bold(mode))} ${c.gray(this.ctx.config.root)}`) + + if (this.ctx.config.ui) + this.ctx.log(c.green(` Vitest UI started at http://${this.ctx.config.api?.host || 'localhost'}:${c.bold(`${this.ctx.server.config.server.port}`)}`)) + else if (this.ctx.config.api) + this.ctx.log(c.green(` Vitest API started at http://${this.ctx.config.api?.host || 'localhost'}:${c.bold(`${this.ctx.config.api.port}`)}`)) + + this.ctx.log() this.start = performance.now() }