mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +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`
|
* Type: `boolean`
|
||||||
* Default: `true`
|
* Default: `true`
|
||||||
|
|
||||||
|
#### `port`
|
||||||
|
|
||||||
|
If provided, set the launched test server port to the value.
|
||||||
|
|
||||||
|
* Type: `number | undefined`
|
||||||
|
* Default: `undefined`
|
||||||
|
|
||||||
#### `build`
|
#### `build`
|
||||||
|
|
||||||
Whether to run a separate build step.
|
Whether to run a separate build step.
|
||||||
|
@ -13,7 +13,7 @@ const kit: typeof _kit = _kit.default || _kit
|
|||||||
export async function startServer () {
|
export async function startServer () {
|
||||||
const ctx = useTestContext()
|
const ctx = useTestContext()
|
||||||
await stopServer()
|
await stopServer()
|
||||||
const port = await getRandomPort()
|
const port = ctx.options.port || await getRandomPort()
|
||||||
ctx.url = 'http://127.0.0.1:' + port
|
ctx.url = 'http://127.0.0.1:' + port
|
||||||
if (ctx.options.dev) {
|
if (ctx.options.dev) {
|
||||||
const nuxiCLI = await kit.resolvePath('nuxi/cli')
|
const nuxiCLI = await kit.resolvePath('nuxi/cli')
|
||||||
|
@ -23,6 +23,7 @@ export interface TestOptions {
|
|||||||
launch?: LaunchOptions
|
launch?: LaunchOptions
|
||||||
}
|
}
|
||||||
server: boolean
|
server: boolean
|
||||||
|
port?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TestContext {
|
export interface TestContext {
|
||||||
|
Loading…
Reference in New Issue
Block a user