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
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
Parameter | Type | Default | Description |
command | string | N/A | Command to start the dev server. If not specified, the dev server will not be started. |
env | Record<string, string> | {} | Environment variables to be passed to the dev server process, in addition to the main process's |
args | string[] | [] | Arguments to be passed to the dev server process. |
cwd | string | The nearest directory with package.json relative to the Testplane config | Working directory of the dev server. |
logs | boolean | true | Enables streaming of dev server logs to the console with the prefix |
readinessProbe | (devServer: ChildProcess) => Promise<void/> | ReadinessProbeOpts | null | 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:
Parameter | Type | Default | Description |
url | string | N/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 |
timeouts | ReadinessProbeTimeouts | see description |
|