FAQ / @knapsack-pro/cypress / Knapsack Pro Cypress specific questions

How to run Cypress tests locally with Knapsack Pro?

You can run Cypress tests using @knapsack-pro/cypress on your local machine instead of the CI environment. Running tests locally can be useful if you need to quickly test your configuration before running changes on the CI server.

Create a bash script bin/knapsack_pro_cypress with the following content:


#!/bin/bash

# The CI build ID must have the same value if you would like to simulate running tests on 2 parallel nodes. You could set the value manually.
# Alternatively, you can use openssl to generate a unique CI build ID. This way running the bash script would simulate running a new CI build.
export CI_BUILD_ID=$(openssl rand -base64 32)

KNAPSACK_PRO_TEST_SUITE_TOKEN_CYPRESS=your_API_token \
KNAPSACK_PRO_TEST_FILE_PATTERN="cypress/e2e/**/*.{js,jsx,coffee,cjsx}"
KNAPSACK_PRO_LOG_LEVEL=info \
KNAPSACK_PRO_CI_NODE_BUILD_ID=$CI_BUILD_ID \
KNAPSACK_PRO_CI_NODE_TOTAL=${2:-2} \
KNAPSACK_PRO_CI_NODE_INDEX=${1:-0} \
$(npm bin)/knapsack-pro-cypress

Then run the following command locally to simulate running tests on the parallel node with index 0 (it's the 1st node out of 2). Note index starts from 0.

bin/knapsack_pro_cypress 0 2

Simulate running tests on the node with index 1 (it's the 2nd node out of 2).

bin/knapsack_pro_cypress 1 2

Start using Knapsack Pro

Sign up and speed up your tests.