Reputation: 9
I am looking at using the cypress parallel = true
option to run tests in parallel through github actions. I currently run tests in parallel a different way and to ensure the parallel instances do not interfere with each other (as am using API to set up and clear down test data at the start of tests etc), I have an environment variable 'testRunName'
which I use within a username (e.g. user1${testRunName}@whatever.io
, user2${testRunName}@whatever.io
, etc) to ensure each parallel test run instance logs in as different users, thereby ensuring the runs do not interfere with each other. My current method of parallelisation is somewhat limited as I have to hardcode the tests which go into each run and I would like to try out the cypress parallel = true
option so that the tests get distributed more intelligently across the different machines.
I am not sure if I will be able to control environment variables like my 'testRunName'
in this way if I use the Cypress parallel = true
option and the documentation does not talk about pointing to different databases or user instances or how to achieve that unless I am missing something!
I basically need to know the instance of the parallel run e.g. "0", "1", "2" etc to be able to build up my unique testRunName
and set this for each parallel instance. Is this even possible? It must be the same name each time as otherwise my tests will keep creating new test users for each run and we have a limit on the number of test users we can generate each month.
A similar thing was possible back in the day when I used to use cucumber selenium to run tests in parallel - basically they made an environment variable PARALLEL_INSTANCE
( = 0, 1, 2, 3 etc) available to the test code so you could use this to do things like point to different databases or user instances.
Upvotes: 0
Views: 945
Reputation: 9
So from playing around and setting up a workflow to run cypress parallel true through github actions, I have worked out how to set my testRunName to include the instance of the paralllel run. Basically you can use ${{ matrix.containers }}. E.g:
.
.
.
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3]
steps
.
.
.
- name: Cypress regression run
uses: cypress-io/github-action@v2
with:
browser: chrome
headless: true
env: xxxxxxxxx
config: xxxxxxxx
spec: xxxxxxxxx
record: true
parallel: true
env:
CYPRESS_testRunName: parallel${{ matrix.containers }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.PAT }}
Upvotes: 0