I am running an Angular 2+ app with integration testing using Cypress.io and CI using circleCI.
I riffed off of a tutorial provided here for setting up an Angular project with circleCI, but needed to add the cypress orbs as well to run Cypress. So I ended up with the following config.yml script:
version: 2.1
orbs:
cypress: cypress-io/[email protected]
jobs:
build:
working_directory: ~/project
docker:
- image: angular/ngcontainer
steps:
- checkout
- run:
name: Show current branch
command: |
echo ${CIRCLE_BRANCH}
echo $fireBaseApiKey
- restore_cache:
keys:
- v1-dependencies-{{checksum "package.json"}}
- v1-dependencies-
- run:
name: Install local dependencies
command: |
npm install
- save_cache:
key: v1-dependencies-{{checksum "package.json"}}
paths:
- node_modules
- run:
name: Building
command: npm run build
- save_cache:
key: v1-dist-{{ .Environment.CIRCLE_BRANCH}}-{{ .Environment.CIRCLE_SHA1}}
paths:
- dist
workflows:
version: 2.1
build:
jobs:
- build
- cypress/install:
requires:
- build
build: 'npm run build'
context: fireBaseApiKey
- cypress/run:
requires:
- cypress/install
- build
start: 'npm start'
context: fireBaseApiKey
When circleCI kicks off, the first two jobs of the workflow are successful (build and cypress/install), but cypress/run produces the following error:
Cypress could not verify that the server set as your 'baseUrl' is running:
Your tests likely make requests to this 'baseUrl' and these tests will fail if you don't boot your server.
Please start this server and then run Cypress again.
I'm guessing that I did not boot the server with the npm run build
command.
I tried adding:
- run:
name: start ng server
command: ng serve
in the "build" job, but then the error was:
/bin/bash: ng: command not found
I tried to find a docker container on dockerhub that would execute ng commands and "angular/ngcontainer" seemed like a good candidate because using circleci/node:6.10-browsers as my docker image per the tutorial link also didn't recognize ng commands.
I guess I'm mostly just way out of my depth here and haven't been able to find an example of an Angular project that uses Cypress and runs CI on circleCI. Having such an example would probably go a long way in helping things make sense. Until then, does anyone have any recommendations for how I might execute a command like ng serve
and do you suppose that would solve my server not booting error?
Update 3 Feb., 2019 19:34:
I added wait-on
after looking into the cypress orb usage a little more per advice advice from a friend on the internet. Thus, my updated -cypress/run
command reads:
...
- cypress/run:
requires:
- cypress/install
- build
start: 'npm start'
wait-on: 'http://localhost:4200'
context: fireBaseApiKey
This seems to wait for an 'http://localhost:4200' that never happens.