Cypress Runner is a command-line interface (CLI) tool designed to launch specified frontend and backend servers before running Cypress tests. The CLI expects to find a .cypressrunnerrc
configuration file in the current working directory (cwd).
To install Cypress Runner, you can use npm:
npm install -g @devmy/cypress-runner
Cypress Runner requires a .cypressrunnerrc
file in the directory where it is executed. This file should export a configuration object that matches the interface CypressRunnerConfig
{
"debug": true,
"startWebServerCommands": [
{ "command": "npm run start:frontend", "name": "frontend" },
{ "command": "npm run start:backend", "name": "backend" }
],
"waitOn": {
"resources": ["http://localhost:3000", "http://localhost:4000"],
"delay": 1000,
"timeout": 30000
}
}
{
"debug": true,
"startWebServerCommands": [
{ "command": "npm run start:frontend", "name": "frontend" },
{ "command": "npm run start:backend", "name": "backend" }
],
"waitOn": {
"resources": ["http://localhost:3000", "http://localhost:4000"],
"delay": 1000,
"timeout": 30000
}
}
/** @type import('@devmy/cypress-runner').CypressRunnerConfig*/
const config = {
debug: true,
startWebServerCommands: [
{ command: "npm run start:frontend", name: "frontend" },
{ command: "npm run start:backend", name: "backend" }
],
waitOn: {
resources: ["http://localhost:3000", "http://localhost:4000"],
delay: 1000,
timeout: 30000
}
};
exports.default = config;
import { CypressRunnerConfig } from '@devmy/cypress-runner';
const config: CypressRunnerConfig = {
debug: true,
startWebServerCommands: [
{ command: "npm run start:frontend", name: "frontend" },
{ command: "npm run start:backend", name: "backend" }
],
waitOn: {
resources: ["http://localhost:3000", "http://localhost:4000"],
delay: 1000,
timeout: 30000
}
};
export default config;
After configuring your .cypressrunnerrc
file, you can run Cypress Runner from your project’s root directory:
cypress-runner [cypress options]
All additional parameters passed to the CLI will be forwarded directly to Cypress.
cypress-runner open
In this example, cypress-runner
will:
- Start the frontend and backend servers as specified in the
.cypressrunnerrc
file. - Wait until the servers are up and running based on the
waitOn
configuration. - Launch the Cypress test runner with the
open
option.
- Type:
boolean
- Description: Enables debug logging for the Cypress Runner.
- Default:
false
- Type:
Array<ConcurrentlyCommandInput>
|ConcurrentlyCommandInput
- Description: Commands to start the frontend and backend servers. This uses the
concurrently
package to run multiple commands concurrently.
- Type:
WaitOnOptions
- Description: Configuration options for the
wait-on
package to wait for resources (such as HTTP endpoints) to become available before starting Cypress.
This project is licensed under the MIT License. See the LICENSE file for more details.