Skip to content

Commit

Permalink
Run Cypress tests in parallell in CI to speed up (#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReedOnly authored Sep 14, 2021
1 parent 5d9f1a7 commit 6fa2b27
Showing 1 changed file with 50 additions and 7 deletions.
57 changes: 50 additions & 7 deletions pipelines/cypress-E2E.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,62 @@ pool:

jobs:
- job: Cypress_E2E_Tests
strategy:
parallel: 4
variables:
npm_config_cache: $(Pipeline.Workspace)/.npm
steps:
- task: DockerCompose@0

- task: NodeTool@0
inputs:
dockerComposeFile: "docker-compose.cypress.yml"
action: "Run a Docker Compose command"
dockerComposeCommand: "build"
versionSpec: "16.x"
displayName: "Install Node.js"

- task: Cache@2
inputs:
key: 'npm | "$(Agent.OS)" | frontend/package-lock.json'
restoreKeys: |
npm | "$(Agent.OS)"'
path: $(npm_config_cache)
displayName: Cache npm
- task: Cache@2
inputs:
key: 'cypress | "$(Agent.OS)" | frontend/package-lock.json'
restoreKeys: |
cypress | "$(Agent.OS)"'
path: /home/vsts/.cache/Cypress
displayName: Cache cypress binary

- task: DockerCompose@0
inputs:
dockerComposeFile: "docker-compose.cypress.yml"
action: "Run a Docker Compose command"
dockerComposeCommand: "up"
arguments: "--exit-code-from cypress cypress"
dockerComposeFileArgs: |
CYPRESS_RECORD_KEY=$(CYPRESS_RECORD_KEY)
arguments: "-d mock-auth"
displayName: "Start mock auth"

- script: |
npm ci
npm start &
workingDirectory: "frontend"
displayName: "Start frontend"
- script: |
dotnet run --no-launch-profile &
env:
ASPNETCORE_ENVIRONMENT: "Test"
workingDirectory: "backend/api"
displayName: "Start backend"
- script: |
npx cypress run \
--env FRONTEND_URL=http://localhost:3000,API_URL=http://localhost:5000,AUTH_URL=http://localhost:8080 \
--config-file ./cypress.json \
--record \
--parallel --ci-build-id $BUILD_BUILDNUMBER --group "Azure CI"
env:
# avoid warnings about terminal
TERM: xterm
CYPRESS_RECORD_KEY: $(CYPRESS_RECORD_KEY)
workingDirectory: "frontend"
displayName: "Run Cypress"

0 comments on commit 6fa2b27

Please sign in to comment.