mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
feat(test-utils): add option to configure test server port (#20443)
This commit is contained in:
parent
24cce84e4b
commit
4e7206bfab
@ -84,6 +84,13 @@ Whether to launch a server to respond to requests in the test suite.
|
||||
* Type: `boolean`
|
||||
* Default: `true`
|
||||
|
||||
#### `port`
|
||||
|
||||
If provided, set the launched test server port to the value.
|
||||
|
||||
* Type: `number | undefined`
|
||||
* Default: `undefined`
|
||||
|
||||
#### `build`
|
||||
|
||||
Whether to run a separate build step.
|
||||
|
@ -13,7 +13,7 @@ const kit: typeof _kit = _kit.default || _kit
|
||||
export async function startServer () {
|
||||
const ctx = useTestContext()
|
||||
await stopServer()
|
||||
const port = await getRandomPort()
|
||||
const port = ctx.options.port || await getRandomPort()
|
||||
ctx.url = 'http://127.0.0.1:' + port
|
||||
if (ctx.options.dev) {
|
||||
const nuxiCLI = await kit.resolvePath('nuxi/cli')
|
||||
|
@ -23,6 +23,7 @@ export interface TestOptions {
|
||||
launch?: LaunchOptions
|
||||
}
|
||||
server: boolean
|
||||
port?: number
|
||||
}
|
||||
|
||||
export interface TestContext {
|
||||
|
Loading…
Reference in New Issue
Block a user