While running the Cypress tests, getting below error in GitHub action pipeline:
The workflow is not valid. .github/workflows/main.yml (Line: 44, Col: 9): Unexpected value 'with'
.
Could someone please advise how can we add browser : chrome
in the yml file at the with:
level.
name: Cypress Automation Tests
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches: [develop]
env:
CYPRESS_BOOKING_FREE_USER_PASSWORD: ${{ secrets.CYPRESS_BOOKING_FREE_USER_PASSWORD }}
jobs:
install:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install dependencies
uses: cypress-io/github-action@v2
with:
# just perform install
runTests: false
tests:
runs-on: ubuntu-22.04
needs: install
steps:
- name: Check out code
uses: actions/checkout@v2
# we re-install the dependencies
- name: Install dependencies
uses: cypress-io/github-action@v2
with:
# just perform install
runTests: false
- name: Run Automation tests
run: npm run cy:run -- --env grepTags="@Envtest1",ENV="staging"
with:
browser: chrome
- name: Upload Results
uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
- uses: actions/upload-artifact@v2
if: always()
with:
name: cypress-videos
path: cypress/videos
3
Answers
Your yml code looks ok to me. This is a formatting issue.
Checked this on an online formatter –
The
with
option isn’t compatible with the run command you gave above it.But it’s ok to use
--browser
Cypress command line option, same as localcy:run
commandRef: cypress run –browser
The pipeline (abbreviated to make it clearer)
@Paolo is correct, you can’t use
with:
on a bash command step. But just to explain a bit more:with:
is only appropriate for steps that use another action.For example, your "Check out code" step calls a standard action,
and you could add
with:
sections to provide custom input to thatThe following is the top of Github’s
checkout
action. Theinputs:
listed there correspond to the validwith:
sections in your own workflow