Skip to content

Commit cf49074

Browse files
authored
Merge pull request #35 from sjetha/add_cypress_coverage
Switch to using Cypress code coverage
2 parents fd1c55c + d00f88f commit cf49074

File tree

13 files changed

+3095
-89
lines changed

13 files changed

+3095
-89
lines changed

.github/workflows/coverage.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,14 @@ jobs:
3636
- name: Install dependencies
3737
run: npm install
3838

39-
- name: Run the tests
40-
run: npm test -- --coverage
39+
- name: Run unit tests
40+
run: npm run test:coverage
41+
42+
- name: Run Cypress tests
43+
run: npm run e2e:ci
44+
45+
- name: Convert test results
46+
run: npx nyc report --reporter=lcov
4147

4248
- name: Upload coverage to Codecov
4349
uses: codecov/codecov-action@v1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ speed-measure-plugin*.json
3838
/.sass-cache
3939
/connect.lock
4040
/coverage
41+
/.nyc_output
4142
/libpeerconnection.log
4243
npm-debug.log
4344
yarn-error.log

.prettierignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@ package.json
22
package-lock.json
33
dist
44
build
5-
cypress
6-
e2e
7-
node_modules
8-
environments
5+
node_modules

.prettierrc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"tabWidth": 2,
3-
"printWidth": 120,
4-
"useTabs": false,
5-
"semi": true,
6-
"singleQuote": true,
7-
"quoteProps": "as-needed",
8-
"bracketSpacing": true,
9-
}
2+
"tabWidth": 2,
3+
"printWidth": 120,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"quoteProps": "as-needed",
8+
"bracketSpacing": true
9+
}

angular.json

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,10 @@
2626
"polyfills": "src/polyfills.ts",
2727
"tsConfig": "src/tsconfig.app.json",
2828
"inlineStyleLanguage": "scss",
29-
"assets": [
30-
"src/favicon.ico",
31-
"src/assets"
32-
],
33-
"styles": [
34-
"src/styles/styles.scss"
35-
],
29+
"assets": ["src/favicon.ico", "src/assets"],
30+
"styles": ["src/styles/styles.scss"],
3631
"stylePreprocessorOptions": {
37-
"includePaths": [
38-
"src/styles/shared"
39-
]
32+
"includePaths": ["src/styles/shared"]
4033
},
4134
"scripts": []
4235
},
@@ -80,7 +73,7 @@
8073
"defaultConfiguration": "production"
8174
},
8275
"serve": {
83-
"builder": "@angular-devkit/build-angular:dev-server",
76+
"builder": "ngx-build-plus:dev-server",
8477
"configurations": {
8578
"production": {
8679
"browserTarget": "ng-new-app:build:production"
@@ -89,7 +82,8 @@
8982
"browserTarget": "ng-new-app:build:development"
9083
}
9184
},
92-
"defaultConfiguration": "development"
85+
"defaultConfiguration": "development",
86+
"options": { "browserTarget": "ng-new-app:build", "extraWebpackConfig": "./cypress/coverage.webpack.js" }
9387
},
9488
"extract-i18n": {
9589
"builder": "@angular-devkit/build-angular:extract-i18n",
@@ -103,24 +97,16 @@
10397
"polyfills": "src/polyfills.ts",
10498
"tsConfig": "tsconfig.spec.json",
10599
"inlineStyleLanguage": "scss",
106-
"assets": [
107-
"src/favicon.ico",
108-
"src/assets"
109-
],
110-
"styles": [
111-
"src/styles.scss"
112-
],
100+
"assets": ["src/favicon.ico", "src/assets"],
101+
"styles": ["src/styles.scss"],
113102
"scripts": []
114103
}
115104
},
116105
"lint": {
117106
"builder": "@angular-eslint/builder:lint",
118107
"options": {
119-
"lintFilePatterns": [
120-
"src/**/*.ts",
121-
"src/**/*.html"
122-
]
123-
}
108+
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
109+
}
124110
},
125111
"cypress-run": {
126112
"builder": "@briebug/cypress-schematic:cypress",

cypress/coverage.webpack.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
module: {
3+
rules: [
4+
{
5+
test: /\.(js|ts)$/,
6+
loader: 'istanbul-instrumenter-loader',
7+
options: { esModules: true },
8+
enforce: 'post',
9+
include: require('path').join(__dirname, '..', 'src'),
10+
exclude: [/\.(e2e|spec)\.ts$/, /node_modules/, /(ngfactory|ngstyle)\.js/],
11+
},
12+
],
13+
},
14+
};

cypress/plugins/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
module.exports = (on, config) => {};
1+
module.exports = (on, config) => {
2+
require('@cypress/code-coverage/task')(on, config);
3+
return config;
4+
};

cypress/support/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515

1616
// When a command from ./commands is ready to use, import with `import './commands'` syntax
1717
// import './commands';
18+
import '@cypress/code-coverage/support';

jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
preset: 'jest-preset-angular',
99
setupFilesAfterEnv: ['../setup-jest.ts'],
1010
collectCoverage: true,
11-
coverageReporters: ['json', 'html', 'text'],
12-
coverageDirectory: '../coverage/',
11+
coverageReporters: ['lcov'],
12+
coverageDirectory: '../coverage/jest',
1313
collectCoverageFrom: ['**/*.ts'],
1414
};

0 commit comments

Comments
 (0)