mirror of
https://github.com/vitest-dev/vitest.git
synced 2026-02-01 17:36:51 +00:00
fix!: don't exit process if config failed (#5715)
This commit is contained in:
parent
9eb84752b4
commit
f232fdd618
@ -193,15 +193,9 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest('t
|
||||
console.log('[debug] watcher is ready')
|
||||
})
|
||||
}
|
||||
try {
|
||||
await ctx.setServer(options, server, userConfig)
|
||||
if (options.api && options.watch)
|
||||
(await import('../../api/setup')).setup(ctx)
|
||||
}
|
||||
catch (err) {
|
||||
ctx.logger.printError(err, { fullStack: true })
|
||||
process.exit(1)
|
||||
}
|
||||
await ctx.setServer(options, server, userConfig)
|
||||
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
|
||||
if (!options.watch)
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { Writable } from 'node:stream'
|
||||
import type { UserConfig } from 'vitest'
|
||||
import type { UserConfig as ViteUserConfig } from 'vite'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
@ -291,7 +290,7 @@ describe.each([
|
||||
waitForDebugger: inspectFlagName === '--inspect-brk' && inspect.enabled,
|
||||
})
|
||||
})
|
||||
it('cannot use a URL', async () => {
|
||||
it('cannot use URL', async () => {
|
||||
const url = 'https://www.remote.com:1002'
|
||||
const rawConfig = parseCLI([
|
||||
'vitest',
|
||||
@ -299,19 +298,8 @@ describe.each([
|
||||
inspectFlagName,
|
||||
url,
|
||||
])
|
||||
const errors: string[] = []
|
||||
const stderr = new Writable({
|
||||
write(chunk, _encoding, callback) {
|
||||
errors.push(chunk.toString())
|
||||
callback()
|
||||
},
|
||||
})
|
||||
await expect(async () => {
|
||||
await config(rawConfig.options, {}, {}, { stderr })
|
||||
}).rejects.toThrowError()
|
||||
|
||||
expect(errors[0]).toEqual(
|
||||
expect.stringContaining(`Inspector host cannot be a URL. Use "host:port" instead of "${url}"`),
|
||||
)
|
||||
await config(rawConfig.options)
|
||||
}).rejects.toThrowError(`Inspector host cannot be a URL. Use "host:port" instead of "${url}"`)
|
||||
})
|
||||
})
|
||||
|
||||
@ -43,8 +43,8 @@ export async function runVitest(config: UserConfig, cliFilters: string[] = [], m
|
||||
})
|
||||
}
|
||||
catch (e: any) {
|
||||
console.error(e.message)
|
||||
cli.stderr += e.message
|
||||
console.error(e)
|
||||
cli.stderr += e.stack
|
||||
}
|
||||
finally {
|
||||
exitCode = process.exitCode
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user