Skip to content

152896: updated to use cypress for automation #12

152896: updated to use cypress for automation

152896: updated to use cypress for automation #12

name: Run Cypress UI tests on isolated environment
on:
pull_request:
branches: [ main, '**-feature' ]
types: [ opened, synchronize, reopened]
push:
branches: [ main ]
env:
NODE_VERSION: 18.13.0
LAST_COMMIT_SHA: default
BRANCH_NAME: main
jobs:
cypress:
name: Set up container and run tests
runs-on: ubuntu-22.04
environment: development
defaults:
run:
working-directory: tests/DFE.FindInformationAcademiesTrusts.CypressTests
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- if: github.event_name == 'pull_request'
name: Get source branch for pull request
run: |
GIT_REF=${{ github.head_ref }}
echo "BRANCH_NAME=${GIT_REF}" >> $GITHUB_ENV
- name: Set SHA environment variable
run: |
echo "LAST_COMMIT_SHA=${GITHUB_SHA:(-7)}" >> $GITHUB_ENV
- name: Install dependencies
run: npm install
- name: Start services
working-directory: ./docker
run: docker compose -f docker-compose.ci.yml up -d
- name: Run the cypress tests
run: npm run cy:run -- --env url=http://localhost,authKey=TestSuperSecret
- name: Upload screenshots
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: screenshots-${{ needs.set-env.outputs.environment }}
path: tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/screenshots
- name: Generate report
if: always()
run: |
mkdir mochareports
npm run generate:html:report
- name: Upload report
if: always()
uses: actions/upload-artifact@v3
with:
name: reports-${{ needs.set-env.outputs.environment }}
path: tests/DFE.FindInformationAcademiesTrusts.CypressTests/mochareports
- name: Stop services
if: always()
working-directory: ./docker
run: docker compose -f docker-compose.ci.yml stop