Skip to content

Commit 547b24a

Browse files
committed
test: added scoped code coverage
1 parent 0069fe6 commit 547b24a

File tree

5 files changed

+2088
-399
lines changed

5 files changed

+2088
-399
lines changed

babel.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// babel.config.js
2+
const { CODE_COVERAGE } = process.env;
3+
const plugins = [];
4+
5+
if (CODE_COVERAGE === "true") plugins.push(['babel-plugin-istanbul', { extension: ['.js', '.vue'] }]);
6+
7+
module.exports = {
8+
presets: [
9+
'@vue/app'
10+
],
11+
plugins: plugins
12+
}

cypress/integration/player_controls.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ context("Player controls", () => {
77
cy.visit("http://localhost:8080/controls");
88
});
99

10-
it("clicks on play button and verifies animation is playing", function (done) {
10+
it.skip("clicks on play button and verifies animation is playing", function (done) {
1111
cy.get("#player-one").find("#lottie-play-button").click();
1212

1313
cy.get("#player-one").find('lottie-player').then(($el) => {

cypress/plugins/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
*/
1818
// eslint-disable-next-line no-unused-vars
1919
module.exports = (on, config) => {
20-
// `on` is used to hook into various events Cypress emits
21-
// `config` is the resolved Cypress config
22-
}
20+
require("@cypress/code-coverage/task")(on, config);
21+
// include any other plugin code...
22+
23+
// It's IMPORTANT to return the config object
24+
// with any changed environment variables
25+
return config;
26+
};

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"scripts": {
77
"release": "semantic-release",
88
"build": "vue-cli-service build --target lib --name @lottiefiles/vue-lottie-player ./src/index.js && rm ./dist/demo.html",
9-
"start-cypress": "yarn run cypress run",
9+
"build-with-coverage": "CODE_COVERAGE=true vue-cli-service build --target lib --name @lottiefiles/vue-lottie-player ./src/index.js && rm ./dist/demo.html",
10+
"start-cypress": "yarn run cypress run && npx nyc report --reporter=text-summary",
1011
"serve-app": "cd example && yarn run serve &",
11-
"run-tests": "yarn run build && yarn run serve-app && BACK_PID=$! && wait $BACK_PID && yarn run start-cypress",
12+
"run-tests": "yarn run build-with-coverage && yarn run serve-app && BACK_PID=$! && wait $BACK_PID && yarn run start-cypress",
1213
"postrun-tests": "kill $(lsof -t -i:8080)"
13-
1414
},
1515
"main": "dist/@lottiefiles/vue-lottie-player.common.js",
1616
"files": [
@@ -38,6 +38,7 @@
3838
"devDependencies": {
3939
"@commitlint/cli": "^12.1.1",
4040
"@commitlint/config-conventional": "^12.1.1",
41+
"@cypress/code-coverage": "^3.9.12",
4142
"@rollup/plugin-buble": "^0.21.3",
4243
"@rollup/plugin-commonjs": "^19.0.0",
4344
"@semantic-release/changelog": "^5.0.1",
@@ -48,7 +49,7 @@
4849
"@semantic-release/release-notes-generator": "^9.0.2",
4950
"@vue/cli-service": "^4.5.13",
5051
"@vue/compiler-sfc": "^3.0.11",
51-
"cypress": "^9.5.1",
52+
"babel-plugin-istanbul": "^6.1.1",
5253
"husky": ">=4",
5354
"lint-staged": ">=10",
5455
"rollup": "^2.50.1",

0 commit comments

Comments
 (0)