Skip to main content

devServer

With the devServer section, you can run a server that tests will interact with. The server starts during the initialization of Testplane on the INIT event.

Example Usage

testplane.config.ts
import type { ConfigInput } from "testplane";

const SERVER_PORT = 3000;

export default {
// ...
devServer: {
command: "npm run server:dev",
env: { PORT: SERVER_PORT },
readinessProbe: {
url: `http://localhost:${SERVER_PORT}/health`,
timeouts: {
// optional
waitServerTimeout: 60_000, // default value
},
},
},
};

devServer Section Reference

ParameterTypeDefaultDescription
commandstringN/A

Command to start the dev server. If not specified, the dev server will not be started.

envRecord<string, string>{}

Environment variables to be passed to the dev server process, in addition to the main process's process.env.

argsstring[][]

Arguments to be passed to the dev server process.

cwdstringThe nearest directory with package.json relative to the Testplane config

Working directory of the dev server.

logsbooleantrue

Enables streaming of dev server logs to the console with the prefix [dev server].

readinessProbe(devServer: ChildProcess) => Promise<void/> | ReadinessProbeOptsnull

Check that the server is ready to accept requests. If not specified, the check is disabled.

command

Command to start the dev server. If not specified, the dev server will not be started.

env

Environment variables to be passed to the dev server process, in addition to the main process's process.env.

args

Arguments to be passed to the dev server process.

cwd

Working directory of the dev server.

logs

Enables streaming of dev server logs to the console with the prefix [dev server].

readinessProbe

Check that the server is ready to accept requests. If not specified, the check is disabled.

If an asynchronous function is provided, Testplane will wait until the resulting promise is resolved. The function type:

type readinessProbeFn = (devServer: ChildProcess) => Promise<void>;

An object of type ReadinessProbeOpts can also be provided:

ParameterTypeDefaultDescription
urlstringN/A

URL that Testplane can check to ensure the server is ready to accept requests. The check is disabled if not specified.

isReady(fetchResponse => bool | Promise<bool>)Function that returns true if the server response status is 2xx

Predicate that determines the server's readiness based on the response to the url request.

timeoutsReadinessProbeTimeoutssee description
  • waitServerTimeout — timeout for waiting for the server to be ready in ms. Default: 60_000.
  • probeRequestTimeout — timeout for a single readiness check request in ms. Default: 10_000.
  • probeRequestInterval — interval between checks in ms. Default: 1_000.