Last active
April 13, 2021 18:40
-
-
Save ArturT/90b7ec869e3827b580664beb086a8cd6 to your computer and use it in GitHub Desktop.
BitBucket Pipeline parallel tests for Cypress with @knapsack-pro/cypress https://knapsackpro.com/?utm_source=github&utm_medium=gist&utm_campaign=gist-bitbucket-pipeline-knapsack-pro-cypress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bitbucket-pipelines.yml | |
# this is example using cypress/base docker image | |
image: cypress/base:10 | |
options: | |
max-time: 30 | |
# job definition for running E2E tests in parallel with KnapsackPro.com | |
e2e: &e2e | |
name: Run E2E tests with @knapsack-pro/cypress | |
caches: | |
- node | |
- cypress | |
script: | |
# run web application in the background | |
- npm run start:ci & | |
# env vars from https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/ | |
- export KNAPSACK_PRO_CI_NODE_BUILD_ID=$BITBUCKET_BUILD_NUMBER | |
- export KNAPSACK_PRO_COMMIT_HASH=$BITBUCKET_COMMIT | |
- export KNAPSACK_PRO_BRANCH=$BITBUCKET_BRANCH | |
- export KNAPSACK_PRO_CI_NODE_TOTAL=$BITBUCKET_PARALLEL_STEP | |
- export KNAPSACK_PRO_CI_NODE_INDEX=$BITBUCKET_PARALLEL_STEP_COUNT | |
# https://github.com/KnapsackPro/knapsack-pro-cypress#configuration-steps | |
- export KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true | |
- $(npm bin)/knapsack-pro-cypress | |
artifacts: | |
# store any generated images and videos as artifacts | |
- cypress/screenshots/** | |
- cypress/videos/** | |
pipelines: | |
default: | |
- step: | |
name: Install dependencies | |
caches: | |
- npm | |
- cypress | |
- node | |
script: | |
- npm ci | |
- parallel: | |
# run N steps in parallel | |
- step: | |
<<: *e2e | |
- step: | |
<<: *e2e | |
- step: | |
<<: *e2e | |
definitions: | |
caches: | |
npm: $HOME/.npm | |
cypress: $HOME/.cache/Cypress |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is example using node docker image. The cypress docker image is used on the parallel step level. | |
image: node:14.15.5 | |
options: | |
max-time: 30 | |
e2e: &e2e | |
name: Run parallel tests with @knapsack-pro/cypress | |
caches: | |
- npm | |
- cypress | |
# cypress docker image | |
image: cypress/included:6.5.0 | |
# env vars from https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/ | |
script: | |
- npm install | |
- npm run start | |
# env vars from https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/ | |
- export KNAPSACK_PRO_COMMIT_HASH=$BITBUCKET_COMMIT | |
- export KNAPSACK_PRO_BRANCH=$BITBUCKET_BRANCH | |
- export KNAPSACK_PRO_CI_NODE_BUILD_ID=$BITBUCKET_BUILD_NUMBER | |
- export KNAPSACK_PRO_CI_NODE_TOTAL=$BITBUCKET_PARALLEL_STEP | |
- export KNAPSACK_PRO_CI_NODE_INDEX=$BITBUCKET_PARALLEL_STEP_COUNT | |
# https://github.com/KnapsackPro/knapsack-pro-cypress#configuration-steps | |
- export KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true | |
- $(npm bin)/knapsack-pro-cypress | |
artifacts: | |
- cypress/reports/** | |
- cypress/videos/** | |
pipelines: | |
default: | |
# How to run parallel tests https://support.atlassian.com/bitbucket-cloud/docs/set-up-or-run-parallel-steps/ | |
# You should add KNAPSACK_PRO_TEST_SUITE_TOKEN_CYPRESS as secure variable https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/ | |
# to not expose Knapsack Pro API token in this config file. | |
- parallel: | |
# run N steps in parallel | |
- step: | |
<<: *e2e | |
- step: | |
<<: *e2e | |
- step: | |
<<: *e2e | |
definitions: | |
caches: | |
npm: $HOME/.npm | |
cypress: $HOME/.cache/Cypress |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@hvaandres
npm run start
command is specific to a project. Maybe you need to start web application in your project with a different command likenpm run start:ci
. You can check that in your projectpackage.json
.Regarding error
Response error body: { errors: [ { node_total: [ 'must be greater than or equal to 2' ] } ] }
You need to double-check if env var has value
BITBUCKET_PARALLEL_STEP
andBITBUCKET_PARALLEL_STEP_COUNT
. They are available in parallel steps only.to display value run: