Skip to content

Commit

Permalink
Add cypress github action
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmadurand committed Nov 4, 2024
1 parent 512edee commit c722db7
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
89 changes: 89 additions & 0 deletions .github/workflows/cypress-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Cypress Tests

on:
push:
branches:
- "feature/*"
pull_request:
branches:
- main

jobs:
install:
runs-on: ubuntu-latest
container:
image: cypress/browsers:node-20.12.0-chrome-123.0.6312.86-1-ff-124.0.2-edge-123.0.2420.65-1
options: --user 1001
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Cypress install
uses: cypress-io/github-action@v6
with:
runTests: false
# report machine parameters
- run: npx cypress info
- run: node --version
- run: node -p 'os.cpus()'
- run: npm run lint

- name: Save build folder
uses: actions/upload-artifact@v4
with:
name: build
if-no-files-found: error
path: build

ui-chrome-tests:
timeout-minutes: 15
runs-on: ubuntu-latest
container:
image: cypress/browsers:node-20.12.0-chrome-123.0.6312.86-1-ff-124.0.2-edge-123.0.2420.65-1
options: --user 1001
needs: install
strategy:
# when one test fails, DO NOT cancel the other
# containers, because this will kill Cypress processes
# leaving Cypress Cloud hanging ...
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: [1, 2, 3, 4, 5]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download the build folders
uses: actions/download-artifact@v4
with:
name: build
path: build

- name: Node info
run: node -v

- name: __e Dir
run: ls /__e

- name: "E2E Tests - Chrome"
uses: cypress-io/github-action@v6
with:
build: yarn cypress info
start: yarn start:ci
wait-on: "http://localhost:3000"
wait-on-timeout: 120
browser: chrome
record: true
parallel: true
group: "E2E - Chrome"
spec: cypress/e2e/*
config-file: cypress.config.ts
env:
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEBUG: "cypress:server:args"
1 change: 1 addition & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ module.exports = defineConfig({
},
env: {
use_mocks: true,
baseUrl: 'http://localhost:3000',
},
});
2 changes: 1 addition & 1 deletion cypress/e2e/layers.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('Layer toggling', () => {
cy.intercept('GET', '/api/weather', { fixture: 'weather.json' }).as('getData');
}

cy.visit('http://localhost:3000');
cy.visit(Cypress.env('baseUrl'));
});

it('should display air layer by default', () => {
Expand Down

0 comments on commit c722db7

Please sign in to comment.