From 4a75858fc4831f378726aa64bec09f2c90f8f68a Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Thu, 14 Mar 2024 18:28:59 +0100 Subject: [PATCH 1/3] fix(vitest): correctly override api with --no-api flag --- packages/vitest/src/node/plugins/index.ts | 2 +- test/config/test/resolution.test.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/vitest/src/node/plugins/index.ts b/packages/vitest/src/node/plugins/index.ts index 09969d21f1bf..c0b1d9b237b0 100644 --- a/packages/vitest/src/node/plugins/index.ts +++ b/packages/vitest/src/node/plugins/index.ts @@ -45,8 +45,8 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest('t const testConfig = deepMerge( {} as UserConfig, configDefaults, - options, removeUndefinedValues(viteConfig.test ?? {}), + options, ) testConfig.api = resolveApiServerConfig(testConfig) diff --git a/test/config/test/resolution.test.ts b/test/config/test/resolution.test.ts index 63d6009dbfc3..97c71abbfc4b 100644 --- a/test/config/test/resolution.test.ts +++ b/test/config/test/resolution.test.ts @@ -235,3 +235,18 @@ describe('correctly defines inline and noExternal flags', async () => { ]) }) }) + +describe('correctly defines api flag', () => { + it('overrides inlined value', async () => { + const c = await vitest({ api: false }, { + api: { + port: 1234, + }, + watch: true, + }) + expect(c.server.config.server.middlewareMode).toBe(true) + expect(c.config.api).toEqual({ + middlewareMode: true, + }) + }) +}) From e886a69cf8a194dff2962b738d1a918ed4c22bda Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Thu, 14 Mar 2024 18:30:46 +0100 Subject: [PATCH 2/3] test: more --api test --- test/config/test/resolution.test.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/config/test/resolution.test.ts b/test/config/test/resolution.test.ts index 97c71abbfc4b..f36b522e5831 100644 --- a/test/config/test/resolution.test.ts +++ b/test/config/test/resolution.test.ts @@ -237,7 +237,7 @@ describe('correctly defines inline and noExternal flags', async () => { }) describe('correctly defines api flag', () => { - it('overrides inlined value', async () => { + it('CLI overrides disabling api', async () => { const c = await vitest({ api: false }, { api: { port: 1234, @@ -249,4 +249,17 @@ describe('correctly defines api flag', () => { middlewareMode: true, }) }) + + it('CLI overrides inlined value', async () => { + const c = await vitest({ api: { port: 4321 } }, { + api: { + port: 1234, + }, + watch: true, + }) + expect(c.server.config.server.port).toBe(4321) + expect(c.config.api).toEqual({ + port: 4321, + }) + }) }) From 1807ee82a035d308902e7c256a7ac5a4d5b85cfb Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Thu, 14 Mar 2024 18:57:26 +0100 Subject: [PATCH 3/3] chore: check for variables --- examples/playwright/test/basic.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/playwright/test/basic.test.ts b/examples/playwright/test/basic.test.ts index 44cee93046d7..4c6631c55b81 100644 --- a/examples/playwright/test/basic.test.ts +++ b/examples/playwright/test/basic.test.ts @@ -20,9 +20,10 @@ describe.runIf(process.platform !== 'win32')('basic', async () => { }) afterAll(async () => { - await browser.close() + // hook timed out and we already have another error + await browser?.close() await new Promise((resolve, reject) => { - server.httpServer.close(error => error ? reject(error) : resolve()) + server?.httpServer.close(error => error ? reject(error) : resolve()) }) })