Skip to content

Commit 51d1d47

Browse files
authored
fix(vitest): correctly override api with --no-api flag (#5386)
1 parent efe441f commit 51d1d47

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

examples/playwright/test/basic.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ describe.runIf(process.platform !== 'win32')('basic', async () => {
2020
})
2121

2222
afterAll(async () => {
23-
await browser.close()
23+
// hook timed out and we already have another error
24+
await browser?.close()
2425
await new Promise<void>((resolve, reject) => {
25-
server.httpServer.close(error => error ? reject(error) : resolve())
26+
server?.httpServer.close(error => error ? reject(error) : resolve())
2627
})
2728
})
2829

packages/vitest/src/node/plugins/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest('t
4545
const testConfig = deepMerge(
4646
{} as UserConfig,
4747
configDefaults,
48-
options,
4948
removeUndefinedValues(viteConfig.test ?? {}),
49+
options,
5050
)
5151
testConfig.api = resolveApiServerConfig(testConfig)
5252

test/config/test/resolution.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,31 @@ describe('correctly defines inline and noExternal flags', async () => {
235235
])
236236
})
237237
})
238+
239+
describe('correctly defines api flag', () => {
240+
it('CLI overrides disabling api', async () => {
241+
const c = await vitest({ api: false }, {
242+
api: {
243+
port: 1234,
244+
},
245+
watch: true,
246+
})
247+
expect(c.server.config.server.middlewareMode).toBe(true)
248+
expect(c.config.api).toEqual({
249+
middlewareMode: true,
250+
})
251+
})
252+
253+
it('CLI overrides inlined value', async () => {
254+
const c = await vitest({ api: { port: 4321 } }, {
255+
api: {
256+
port: 1234,
257+
},
258+
watch: true,
259+
})
260+
expect(c.server.config.server.port).toBe(4321)
261+
expect(c.config.api).toEqual({
262+
port: 4321,
263+
})
264+
})
265+
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy