From e8468d2f64a1fc6063531f7f3c6c5da6dc07fb6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez?= Date: Mon, 21 Feb 2022 07:01:49 +0100 Subject: [PATCH] fix(config): ui and api regression (#820) * fix(ui/api): ui and api regression The ui and the api are not started * chore: wrong entry for port if statement * chore: update server entries only if defined * chore: update Co-authored-by: Anthony Fu --- packages/ui/client/auto-imports.d.ts | 4 ++++ packages/vitest/src/node/plugins/index.ts | 4 ++-- packages/vitest/src/node/reporters/base.ts | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 4 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 7ecee6e57576..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 @@ -110,7 +110,7 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest()) 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() }