Skip to content
This repository was archived by the owner on Oct 13, 2022. It is now read-only.

Commit b41b358

Browse files
author
Kevin Old
committed
Configure Cypress Code Coverage plugin
1 parent 4ed458c commit b41b358

File tree

7 files changed

+743
-13
lines changed

7 files changed

+743
-13
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["next/babel"],
3+
"plugins": ["istanbul"]
4+
}

setup-create-next-app-webpack-4/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# testing
99
/coverage
10+
/.nyc_output
1011

1112
# next.js
1213
/.next/
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
const { defineConfig } = require('cypress')
22
const { devServer } = require('@cypress/react/plugins/next')
3+
const codeCoverageTask = require("@cypress/code-coverage/task")
34

45
module.exports = defineConfig({
6+
coverage: true,
7+
codeCoverage: {
8+
exclude: "cypress/**/*.*",
9+
},
510
component: {
611
devServer,
12+
devServerConfig: {},
13+
setupNodeEvents(on, config) {
14+
codeCoverageTask(on, config);
15+
return config;
16+
},
717
},
818
})

setup-create-next-app-webpack-4/cypress/support/component.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
// https://on.cypress.io/configuration
1414
// ***********************************************************
1515

16+
import '@cypress/code-coverage/support'
17+
1618
// Import commands.js using ES2015 syntax:
1719
import './commands'
1820

1921
// Alternatively you can use CommonJS syntax:
20-
// require('./commands')
22+
// require('./commands')
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
// Webpack 5 is enabled by default
3+
// You can still use webpack 4 while upgrading to the latest version of Next.js by adding the "webpack5: false" flag
4+
webpack5: false,
5+
}

setup-create-next-app-webpack-4/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
"react-dom": "^17.0.2"
1212
},
1313
"devDependencies": {
14+
"@cypress/code-coverage": "3.10.0-dev.1",
1415
"@cypress/react": "^5.12.4",
1516
"@cypress/webpack-dev-server": "^1.8.3",
17+
"babel-plugin-istanbul": "^6.1.1",
1618
"cypress": "https://cdn.cypress.io/beta/npm/10.0.0/linux-x64/10.0-release-188b9a742ee2ef51102167bfd84b3696a3f72a26/cypress.tgz",
1719
"html-webpack-plugin": "4",
1820
"webpack": "4",

0 commit comments

Comments
 (0)