Package Exports
- @devmy/cypress-runner
Readme
Cypress Runner
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).
Installation
To install Cypress Runner, you can use npm:
npm install -g @devmy/cypress-runnerConfiguration
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
Example .cypressrunnerrc File
{
"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
}
}Example .cypressrunnerrc.json File
{
"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
}
}Example .cypressrunnerrc.js File
/** @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;Example .cypressrunnerrc.ts File
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;Usage
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.
Example
cypress-runner openIn this example, cypress-runner will:
- Start the frontend and backend servers as specified in the
.cypressrunnerrcfile. - Wait until the servers are up and running based on the
waitOnconfiguration. - Launch the Cypress test runner with the
openoption.
Options
debug
- Type:
boolean - Description: Enables debug logging for the Cypress Runner.
- Default:
false
startWebServerCommands
- Type:
Array<ConcurrentlyCommandInput>|ConcurrentlyCommandInput - Description: Commands to start the frontend and backend servers. This uses the
concurrentlypackage to run multiple commands concurrently.
waitOn
- Type:
WaitOnOptions - Description: Configuration options for the
wait-onpackage to wait for resources (such as HTTP endpoints) to become available before starting Cypress.
License
This project is licensed under the MIT License. See the LICENSE file for more details.