Skip to content

Commit 80aa2a7

Browse files
committed
test: add code-coverage
1 parent 3ec4166 commit 80aa2a7

File tree

8 files changed

+1761
-204
lines changed

8 files changed

+1761
-204
lines changed

.eslintrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
},
66
"extends": [
77
"airbnb",
8-
"plugin:react/recommended",
98
"plugin:@typescript-eslint/recommended",
109
"prettier",
10+
"plugin:react/recommended",
1111
"plugin:cypress/recommended"
1212
],
1313
"globals": {
@@ -24,6 +24,8 @@
2424
},
2525
"plugins": ["react", "react-hooks", "@typescript-eslint", "prettier"],
2626
"rules": {
27+
"import/no-import-module-exports": "off",
28+
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
2729
"import/prefer-default-export": "off",
2830
"prettier/prettier": "error",
2931
"import/extensions": [
@@ -40,6 +42,8 @@
4042
"allowExpressions": true
4143
}
4244
],
45+
"@typescript-eslint/no-var-requires": "off",
46+
"global-require": "off",
4347
"react-hooks/rules-of-hooks": "error",
4448
"react-hooks/exhaustive-deps": "warn",
4549
"comma-dangle": "off",

.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
# production
1213
/build

cypress/plugins/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@
1515
/**
1616
* @type {Cypress.PluginConfig}
1717
*/
18-
// eslint-disable-next-line no-unused-vars
1918
module.exports = (on, config) => {
2019
// `on` is used to hook into various events Cypress emits
2120
// `config` is the resolved Cypress config
21+
require('@cypress/code-coverage/task')(on, config);
22+
// include any other plugin code...
23+
24+
// It's IMPORTANT to return the config object
25+
// with any changed environment variables
26+
return config;
2227
};

cypress/support/index.js

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

1616
// Import commands.js using ES2015 syntax:
1717
import './commands.js';
18+
import '@cypress/code-coverage/support';
1819

1920
// Alternatively you can use CommonJS syntax:
2021
// require('./commands')

package.json

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@
99
"Basile Spaenlehauer"
1010
],
1111
"dependencies": {
12-
"@testing-library/cypress": "^8.0.2",
13-
"@testing-library/jest-dom": "^5.14.1",
14-
"@testing-library/react": "^13.0.0",
15-
"@testing-library/user-event": "^13.2.1",
16-
"@types/jest": "^27.0.1",
17-
"@types/node": "^16.7.13",
18-
"@types/react": "^18.0.0",
19-
"@types/react-dom": "^18.0.0",
20-
"react": "^18.1.0",
21-
"react-dom": "^18.1.0",
12+
"@testing-library/cypress": "8.0.2",
13+
"@testing-library/jest-dom": "5.16.4",
14+
"@testing-library/react": "13.2.0",
15+
"@testing-library/user-event": "14.1.1",
16+
"@types/jest": "27.5.0",
17+
"@types/node": "16.11.33",
18+
"@types/react": "18.0.8",
19+
"@types/react-dom": "18.0.3",
20+
"react": "18.1.0",
21+
"react-dom": "18.1.0",
2222
"react-scripts": "5.0.1",
23-
"typescript": "^4.4.2"
23+
"typescript": "4.6.4"
2424
},
2525
"scripts": {
26-
"start": "env-cmd -f ./.env.local react-scripts start",
26+
"start": "env-cmd -f ./.env.local react-scripts -r @cypress/instrument-cra start",
2727
"start:test": "env-cmd -f ./.env.test react-scripts -r @cypress/instrument-cra start",
2828
"build": "react-scripts build",
2929
"test": "react-scripts test",
@@ -33,31 +33,35 @@
3333
"hooks:install": "husky install",
3434
"hooks:uninstall": "husky uninstall",
3535
"lint": "eslint .",
36+
"cypress:open": "env-cmd -f ./.env.local cypress open",
3637
"test:once": "concurrently -k -s first \"yarn start:test\" \"wait-on http://localhost:3333 && yarn test:ci\" ",
37-
"test:ci": "env-cmd -f ./.env.test cypress run --headless"
38+
"test:ci": "env-cmd -f ./.env.test cypress run && nyc report --reporter=text --reporter=text-summary",
39+
"cov:report": "open ./coverage/lcov-report/index.html"
3840
},
3941
"devDependencies": {
40-
"@commitlint/cli": "16.1.0",
41-
"@commitlint/config-conventional": "16.0.0",
42-
"@cypress/instrument-cra": "^1.4.0",
43-
"@typescript-eslint/eslint-plugin": "^5.22.0",
44-
"@typescript-eslint/parser": "^5.22.0",
45-
"concurrently": "^7.1.0",
46-
"cypress": "^9.6.0",
47-
"eslint": "^8.14.0",
48-
"eslint-config-airbnb": "^19.0.4",
49-
"eslint-config-prettier": "^8.5.0",
50-
"eslint-import-resolver-typescript": "^2.7.1",
51-
"eslint-plugin-cypress": "^2.12.1",
52-
"eslint-plugin-import": "^2.26.0",
53-
"eslint-plugin-jsx-a11y": "^6.5.1",
54-
"eslint-plugin-prettier": "^4.0.0",
55-
"eslint-plugin-react": "^7.29.4",
56-
"eslint-plugin-react-hooks": "^4.5.0",
57-
"husky": "^7.0.4",
58-
"prettier": "^2.6.2",
59-
"pretty-quick": "^3.1.3",
60-
"standard-version": "^9.3.2"
42+
"@commitlint/cli": "16.2.4",
43+
"@commitlint/config-conventional": "16.2.4",
44+
"@cypress/code-coverage": "3.9.12",
45+
"@cypress/instrument-cra": "1.4.0",
46+
"@typescript-eslint/eslint-plugin": "5.22.0",
47+
"@typescript-eslint/parser": "5.22.0",
48+
"concurrently": "7.1.0",
49+
"cypress": "9.6.0",
50+
"eslint": "8.14.0",
51+
"eslint-config-airbnb": "19.0.4",
52+
"eslint-config-prettier": "8.5.0",
53+
"eslint-import-resolver-typescript": "2.7.1",
54+
"eslint-plugin-cypress": "2.12.1",
55+
"eslint-plugin-import": "2.26.0",
56+
"eslint-plugin-jsx-a11y": "6.5.1",
57+
"eslint-plugin-prettier": "4.0.0",
58+
"eslint-plugin-react": "7.29.4",
59+
"eslint-plugin-react-hooks": "4.5.0",
60+
"husky": "7.0.4",
61+
"nyc": "15.1.0",
62+
"prettier": "2.6.2",
63+
"pretty-quick": "3.1.3",
64+
"standard-version": "9.3.2"
6165
},
6266
"browserslist": {
6367
"production": [
@@ -71,5 +75,13 @@
7175
"last 1 safari version"
7276
]
7377
},
78+
"nyc": {
79+
"all": true,
80+
"include": "src/*.{js,ts,jsx,tsx}",
81+
"exclude": [
82+
"src/setupTests.ts",
83+
"src/*.d.ts"
84+
]
85+
},
7486
"packageManager": "[email protected]"
7587
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"isolatedModules": true,
1616
"noEmit": true,
1717
"jsx": "react-jsx",
18-
"types": ["cypress"]
18+
"types": ["node", "cypress"]
1919
},
2020
"include": ["src"]
2121
}

0 commit comments

Comments
 (0)