cypress-io / github-action

GitHub Action for running Cypress end-to-end & component tests

Home Page:https://on.cypress.io/guides/continuous-integration/github-actions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Config parameter seems not to override cypress config file

sauldeleon opened this issue · comments

Hello all!

I am struggling with a config issue. Seems that the config parameter in the github action is not overriding the default config. Here is my *.yml file

name: End-to-end tests
on:
  workflow_call:
    secrets:
      vercel-token:
        required: true
      vercel-project-id:
        required: true

jobs:
  cypress-run:
    runs-on: ubuntu-22.04
    steps:
      - name: vercel-preview-url
        uses: zentered/vercel-preview-url@v1.1.9
        id: vercel_preview_url
        env:
          VERCEL_TOKEN: ${{ secrets.vercel-token }}
        with:
          vercel_project_id: ${{ secrets.vercel-project-id }}
      - name: Output Vercel Preview URL
        run: echo "The preview url is -> https://${{ steps.vercel_preview_url.outputs.preview_url }}"
      - uses: UnlyEd/github-action-await-vercel@v1.2.42
        id: await-vercel-preview-ready
        env:
          VERCEL_TOKEN: ${{ secrets.vercel-token }}
        with:
          deployment-url: ${{ steps.vercel_preview_url.outputs.preview_url }}
          timeout: 300
      - name: Display deployment status
        run: 'echo The deployment at ${{ fromJson(steps.await-vercel-preview-ready.outputs.deploymentDetails).url }} is ${{ fromJson(steps.await-vercel-preview-ready.outputs.deploymentDetails).readyState }}'
      - name: Checkout repo
        uses: actions/checkout@v3
      - name: Install
        uses: actions/setup-node@v3
        with:
          node-version: 18
          cache: 'yarn'
      - name: Install cypress dependencies
        uses: bahmutov/npm-install@v1
        with:
          working-directory: apps/web-e2e
      - name: Cypress run
        if: steps.vercel_preview_url.outcome == 'success'
        uses: cypress-io/github-action@v6
        with:
          working-directory: apps/web-e2e
          wait-on: 'https://${{ steps.vercel_preview_url.outputs.preview_url }}'
          command: npm run e2e
          config: baseUrl=https://${{ steps.vercel_preview_url.outputs.preview_url }}

The npm run e2e just triggers cypress run

And the config file is as follows:

import { defineConfig } from 'cypress'

export default defineConfig({
  e2e: {
    fileServerFolder: '.',
    specPattern: 'src/**/*.cy.{js,jsx,ts,tsx}',
    fixturesFolder: 'src/fixtures',
    supportFile: 'src/support/e2e.ts',
    chromeWebSecurity: true,
    screenshotOnRunFailure: true,
    screenshotsFolder: 'screenshots',
    baseUrl: 'http://localhost:4200',
  },
})

If I switch the cypress build section to

      - name: Cypress run
        if: steps.vercel_preview_url.outcome == 'success'
        uses: cypress-io/github-action@v6
        with:
          working-directory: apps/web-e2e
          wait-on: 'https://${{ steps.vercel_preview_url.outputs.preview_url }}'
          command: npm run e2e -- --config baseUrl=https://${{ steps.vercel_preview_url.outputs.preview_url }}

it overrides the cypress.config.ts file correctly

@sauldeleon

Your problem is the use of command:

Caution: using the action parameter command causes multiple other parameters to be ignored including: auto-cancel-after-failures, browser, ci-build-id, command-prefix, component, config, config-file, env, group, headed, parallel, project, publish-summary, quiet, record, spec and tag.

What is the script definition of e2e?


The following is unnecessary, because cypress-io/github-action does this work for you. See README > Installation. This is not the cause of your problems though. It is just a suggested optimization to remove it.

      - name: Install cypress dependencies
        uses: bahmutov/npm-install@v1
        with:
          working-directory: apps/web-e2e

Thanks @MikeMcC399 for the tip. I removed that bunch of code and indeed it worked.

I removed the command parameter, and now the config is as follows:

      - name: Install
        uses: actions/setup-node@v3
        with:
          node-version: 18
          cache: 'yarn'
      - name: Cypress run
        if: steps.vercel_preview_url.outcome == 'success'
        uses: cypress-io/github-action@v6
        with:
          working-directory: apps/web-e2e
          wait-on: 'https://${{ steps.vercel_preview_url.outputs.preview_url }}'
          config: baseUrl=https://${{ steps.vercel_preview_url.outputs.preview_url }}

the scripts

  "scripts": {
    "e2e": "cypress run",
  },

Im running a new pipeline to verify if it works without specifying a command, but it seems that the only bug is on my eyes that are uncapable of read the docs correctly

@MikeMcC399 I can confirm its working now. Closing. Thanks for your help!