Skip to content

Commit

Permalink
fix: Fix cypress test coverage (#434)
Browse files Browse the repository at this point in the history
This updates the cypress configs so that the coverage plugin can work
again with component tests.
  • Loading branch information
gkarat committed Oct 17, 2022
1 parent baf20ba commit 3190ca0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 26 deletions.
1 change: 0 additions & 1 deletion coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mkdir -p reports

cp cypress-coverage/coverage-final.json reports/from-cypress.json
cp jest-coverage/coverage-final.json reports/from-jest.json
rm -rf cypress-coverage jest-coverage

npx nyc merge reports .nyc_output/out.json
npx nyc report --reporter json --report-dir coverage
Expand Down
5 changes: 5 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { defineConfig } = require('cypress');
const webpackConfig = require('./config/cypress.webpack.config.js');
const codeCoverageTask = require('@cypress/code-coverage/task');

module.exports = defineConfig({
viewportWidth: 1000,
Expand All @@ -12,5 +13,9 @@ module.exports = defineConfig({
webpackConfig,
},
specPattern: 'src/**/*.cy.{js,ts,jsx,tsx}',
setupNodeEvents(on, config) {
codeCoverageTask(on, config);
return config;
},
},
});
1 change: 1 addition & 0 deletions cypress/support/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

// Import commands.js using ES2015 syntax:
import './commands';
import '@cypress/code-coverage/support';

// Alternatively you can use CommonJS syntax:
// require('./commands')
Expand Down
23 changes: 0 additions & 23 deletions cypress/support/index.js

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
"test:ct": "cypress run --component",
"test:jest": "TZ=UTC jest --verbose --passWithNoTests --no-cache",
"test": "npm run test:ct && npm run test:jest",
"coverage": "bash coverage.sh",
"translations": "npm-run-all translations:*",
"translations:extract": "formatjs extract 'src/**/*.js*' --out-file lang/en.json --id-interpolation-pattern '[sha512:contenthash:base64:6]'",
"translations:compile": "formatjs compile lang/en.json --out-file compiled-lang/en.json",
"verify": "npm-run-all build lint test",
"release": "semantic-release",
"report:combined": "npx nyc report --reporter lcov --reporter text --report-dir coverage"
"coverage:clean": "rm -rf .nyc_output coverage reports",
"coverage": "bash coverage.sh && npm run coverage:clean"
},
"dependencies": {
"@patternfly/react-core": "^4.224.1",
Expand Down

0 comments on commit 3190ca0

Please sign in to comment.