Skip to content

Continuous Integration (CI)

Mark edited this page Jun 20, 2024 · 4 revisions

GitHub Actions

Create .github/workflows/cypress.yml:

touch .github/workflows/cypress.yml

Update .github/workflows/cypress.yml:

name: cypress
on: push # or pull_request

jobs:
  cypress:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v3

      - name: Cypress run
        uses: cypress-io/github-action@v6
        with:
          browser: chrome
          start: npm start # update start command here
          wait-on: 'http://localhost:3000' # update server url here

      - name: Record failed screenshots
        if: failure()
        uses: actions/upload-artifact@v3
        with:
          name: cypress-screenshots
          path: cypress/screenshots

      - name: Record videos
        if: failure()
        uses: actions/upload-artifact@v3
        with:
          name: cypress-videos
          path: cypress/videos

To enable video in cypress.config.ts:

export default defineConfig({
  // ...
  video: true,
});

To enable retries in cypress.config.ts:

export default defineConfig({
  // ...
  retries: {
    runMode: 2,
  },
});
Clone this wiki locally