Skip to content

Backend code coverage tests, refactor #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 47 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
version: 2.1
orbs:
cypress: cypress-io/cypress@1.13.0
cypress: cypress-io/cypress@1.13.0 # used to run e2e tests
node: circleci/node@1.1.6 # used to publish new NPM version

jobs:
publish:
executor:
name: node/default
tag: '12'
steps:
- checkout
- node/with-cache:
steps:
- run: npm ci
- run: npm run semantic-release

workflows:
build:
jobs:
- cypress/install
- cypress/run:
name: frontend coverage
requires:
- cypress/install
# we need to start the web application
start: npm start
# there are no jobs to follow this one
Expand All @@ -23,5 +41,31 @@ workflows:
- run: npx nyc report --check-coverage true --lines 100 --include cypress/about.js
# make sure unit tests are covered
- run: npx nyc report --check-coverage true --lines 100 --include cypress/unit.js
# publish new version if necessary
- run: npm run semantic-release

- cypress/run:
name: backend coverage
requires:
- cypress/install

start: npm run start:test:backend
command: npx cypress run --config-file cypress-backend.json

# there are no jobs to follow this one
# so no need to save the workspace files (saves time)
no-workspace: true
post-steps:
# store the created coverage report folder
# you can click on it in the CircleCI UI
# to see live static HTML site
- store_artifacts:
path: coverage
# print code coverage summary to the terminal
# and make sure there the coverage is above certain limit
- run: npx nyc report --check-coverage true --lines 85
# and look at the server index file - should be fully covered
- run: npx nyc report --check-coverage true --lines 100 --include test-backend/index.js

- publish:
requires:
- frontend coverage
- backend coverage
9 changes: 9 additions & 0 deletions cypress-backend.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"baseUrl": "http://localhost:3003",
"integrationFolder": "cypress/test-backend",
"env": {
"codeCoverage": {
"url": "http://localhost:3003/__coverage__"
}
}
}
5 changes: 5 additions & 0 deletions cypress/test-backend/spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="Cypress" />
it('has backend code coverage', () => {
cy.visit('/')
cy.request('/hello')
})
Loading