FAQ / @knapsack-pro/jest / Knapsack Pro Jest specific questions

How to run Jest tests locally with Knapsack Pro?

You can run Jest tests using @knapsack-pro/jest 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_jest with the following content:


# 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)

$(npm bin)/knapsack-pro-jest --runInBand

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_jest 0 2

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

bin/knapsack_pro_jest 1 2

Start using Knapsack Pro

Sign up and speed up your tests.