Skip to content
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

Add coverage reports to e2e tests #443

Merged
merged 8 commits into from
Apr 28, 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
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage/lcov.info
flags: unittests
fail_ci_if_error: false
- name: Build
run: yarn run build
Expand All @@ -47,3 +48,10 @@ jobs:
env:
CYPRESS_baseUrl: http://localhost:8080/
NODE_ENV: offline
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not kick in until merged as secrets are not exposed to forks.

Annoyingly GitHub doesn't raise an error if a template variable is unset, it just gives you an empty string.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I thought it was working for the other coverage report (I copied this block from the existing line for unit tests coverage)

file: ./coverage/lcov.info
flags: e2e
fail_ci_if_error: false
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ Or for headless mode

yarn run test:e2e -- --headless --config video=false

For coverage

yarn run coverage:e2e

### Lints and fixes files

yarn run lint
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"build:watch": "vue-cli-service build --watch --mode development",
"checkpoint": "./src/services/mock/generate",
"coverage:unit": "nyc vue-cli-service test:unit",
"coverage:e2e": "nyc vue-cli-service test:e2e",
"dev": "yarn run serve",
"lint": "vue-cli-service lint",
"serve": "NODE_ENV=offline vue-cli-service serve",
Expand Down Expand Up @@ -52,6 +53,7 @@
"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@cypress/webpack-preprocessor": "^5.1.2",
"@cypress/code-coverage": "^2.0.5",
"@mdi/font": "^4.5.95",
"@vue/cli-plugin-babel": "^3.12.0",
"@vue/cli-plugin-e2e-cypress": "^4.3.1",
Expand All @@ -73,9 +75,10 @@
"eslint-config-vuetify": "^0.5.0",
"eslint-plugin-vue": "^6.2.2",
"istanbul-instrumenter-loader": "^3.0.1",
"istanbul-lib-coverage": "^3.0.0",
"lodash": "^4.17.15",
"null-loader": "^3.0.0",
"nyc": "^15.0.0",
"nyc": "^15.0.1",
"sass": "^1.26.3",
"sass-loader": "^8.0.2",
"sinon": "^7.5.0",
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const webpack = require('@cypress/webpack-preprocessor')

module.exports = (on, config) => {
// For test coverage
on('task', require('@cypress/code-coverage/task'))
const webpackOptions = require('@vue/cli-service/webpack.config')
// NOTE: if we do not remove the webpack optimizations, Cypress seems
// to get confused when our JS code imports scss, failing
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
// https://on.cypress.io/configuration
// ***********************************************************

// For test coverage
import '@cypress/code-coverage/support'

// Import commands.js using ES2015 syntax:
import './commands'

Expand Down
2 changes: 1 addition & 1 deletion vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
]
},
chainWebpack: config => {
if (process.env.NODE_ENV === 'test') {
if (['test', 'offline'].includes(process.env.NODE_ENV)) {
config.module.rule('istanbul')
.test(/\.js$/)
.include.add(path.resolve('src')).end()
Expand Down
968 changes: 897 additions & 71 deletions yarn.lock

Large diffs are not rendered by default.