Vitest Reference
You can configure things in two ways:
- Command-line arguments for the test runner
- Environment variables for Knapsack Pro or Node
Unless specified otherwise, everything on this page is environment variables.
Command-line arguments
You can pass all the supported Vitest CLI options as command-line arguments:
npx @knapsack-pro/vitest --coverage
KNAPSACK_PRO_BRANCH
Git branch under test.
You don't need to set it if either:
- Your CI is one of the supported CIs
- Your CI has git installed so that Knapsack Pro can retrieve it
In some cases, particularly for pull request merge commits or if the CI provider checks out a specific git commit during the build process, Git might only expose HEAD instead of the actual branch name.
KNAPSACK_PRO_CI_NODE_BUILD_ID
Unique ID that identifies a CI build. It must be the same for all the parallel CI nodes.
Default: Knapsack Pro will take it from the CI environment (see supported CIs)
If your CI is not supported, you may generate a build ID with KNAPSACK_PRO_CI_NODE_BUILD_ID=$(openssl rand -base64 32) and make it available to all parallel nodes.
KNAPSACK_PRO_CI_NODE_INDEX
Index of current CI node (first should be 0, second should be 1, etc.).
Default: Knapsack Pro will take it from the CI environment (see supported CIs)
If your CI is not supported, you need to set it manually.
KNAPSACK_PRO_CI_NODE_RETRY_COUNT
A retry count of the current CI node in case of a single node/job retry.
There is no need to set this for the following CI providers that are supported out of the box:
- GitHub Actions
- Buildkite
For other CI providers:
If you use KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true, you need to set KNAPSACK_PRO_CI_NODE_RETRY_COUNT=1 when retrying a single node to disable Fallback Mode. Otherwise, the CI node would use a different (fallback) split and run a different subset of tests when the API cannot be reached.
Default: 0 (or an environment variable for supported CI providers)
Available:
0: Fallback Mode is enabled> 0: Fallback Mode is disabled and Knapsack Pro raises an error if the API cannot be reached
KNAPSACK_PRO_CI_NODE_TOTAL
Total number of parallel CI nodes.
Default: Knapsack Pro will take it from the CI environment (see supported CIs)
If your CI is not supported, you need to set it manually.