{"id":18773749,"url":"https://github.com/janumedia/vue-cypress-example","last_synced_at":"2026-04-29T09:37:07.627Z","repository":{"id":37022309,"uuid":"266688695","full_name":"janumedia/vue-cypress-example","owner":"janumedia","description":"Vue Unit and E2E Test with Code Coverage Example using Cypress.io","archived":false,"fork":false,"pushed_at":"2022-12-12T21:42:38.000Z","size":2258,"stargazers_count":2,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-21T02:46:12.381Z","etag":null,"topics":["code-coverage","cypress","e2e-tests","unit-tests","vue","vue-test-utils","vue-testing-library"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/janumedia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-25T05:11:43.000Z","updated_at":"2022-01-20T22:58:39.000Z","dependencies_parsed_at":"2023-01-28T01:31:38.926Z","dependency_job_id":null,"html_url":"https://github.com/janumedia/vue-cypress-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/janumedia/vue-cypress-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janumedia%2Fvue-cypress-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janumedia%2Fvue-cypress-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janumedia%2Fvue-cypress-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janumedia%2Fvue-cypress-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janumedia","download_url":"https://codeload.github.com/janumedia/vue-cypress-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janumedia%2Fvue-cypress-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32420350,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-coverage","cypress","e2e-tests","unit-tests","vue","vue-test-utils","vue-testing-library"],"created_at":"2024-11-07T19:35:18.609Z","updated_at":"2026-04-29T09:37:07.602Z","avatar_url":"https://github.com/janumedia.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vue-cypress-example\n\nVue Unit and E2E Test with Code Coverage using Cypress setup example\n\nFor Vue-Typescript version please [check here](https://github.com/janumedia/vue-typescript-cypress-example)\n\n## Step by step setup\n\n\u003e This project example is based on Vue CLI 3.\n\n1. Create Vue project using Vue CLI\n   ```\n   vue create your-app\n   cd your-app\n   ```\n   \u003e Make sure to select Cypress as your E2E test\n2. Add `@vue/test-utils`\n   ```\n   yarn add -D @vue/test-utils\n   ```\n3. Add `@cypress/webpack-preprocessor`, `find-webpack` and `babel-plugin-istanbul`\n   ```\n   yarn add -D @cypress/webpack-preprocessor find-webpack babel-plugin-istanbul\n   ```\n4. Edit Cypress plugins setting locate at `tests/e2e/plugins/index.js`\n\n   4.a. Import `webpack-preprocessor`\n\n   ```\n   const webpackPreprocessor = require(\"@cypress/webpack-preprocessor\");\n   ```\n\n   4.b. Get webpackOptions\n\n   ```\n   const fw = require(\"find-webpack\");\n   const webpackOptions = fw.getWebpackOptions();\n   ```\n\n   4.c. Add on `file:preprocessor` setting\n\n   ```\n   on(\n       \"file:preprocessor\",\n       webpackPreprocessor({ webpackOptions })\n   );\n   ```\n\n   \u003e This setting will allow Cypress to parse .vue files in unit test\n\n   4.d. Setup code coverage task\n   ```\n   require(\"@cypress/code-coverage/task\")(on, config);\n   ```\n5. Edit Cypress support setting locate at `tests/e2e/support/index.js`\n    ```\n    import \"@cypress/code-coverage/support\";\n    ```\n6. Add `istanbul`as Babel plugins config\n    ```\n    plugins: [\"istanbul\"]\n    ```\n7. Create `.nycrc` or`nyc` config file with following\n    ```\n    {\n      \"extension\": [ \".js\", \".vue\" ]\n    }\n    ```\n\u003e Step 4.d, 5 - 7 are related to Code Coverage setup \n\n## Writes your test specs\n\n\u003e Vue-CLI by default set test files location in `tests/e2e/specs`, but you can customize them in `cypress.json` or in plugins settings\n\n#### Example E2E test with Cypress\n```\n//tests/e2e/specs/test.js\n\ndescribe(\"My First Test\", () =\u003e {\n    it(\"Visits the app root url\", () =\u003e {\n        cy.visit(\"/\");\n        cy.contains(\"h1\", \"Welcome to Your Vue.js App\");\n    });\n});\n```    \n\u003e More detail about Cypress API see [Cypress API Docs](https://docs.cypress.io/api/introduction/api.html)\n\n#### Example Unit test with `@vue/test-utils` and Cypress\n\n```\n//tests/e2e/specs/test.unit.js\n\nimport { shallowMount } from \"@vue/test-utils\";\nimport HelloWorld from \"@/components/HelloWorld.vue\";\n\ndescribe(\"HelloWorld\", () =\u003e {\n  const msg = \"Vue Unit and E2E Test with Cypress\";\n  it(`Title should display '${msg}'`, () =\u003e {\n    HelloWorld.components = HelloWorld.components || {};\n    let wrapper = shallowMount(HelloWorld, { propsData: { msg } });\n    expect(wrapper.find(\"h1\").text()).eq(msg);\n  });\n  it(`Title should be empty`, () =\u003e {\n    HelloWorld.components = HelloWorld.components || {};\n    let wrapper = shallowMount(HelloWorld, {});\n    expect(wrapper.find(\"h1\").text()).to.be.empty;\n  });\n});\n```\n\n\u003e Make sure to put unit test files the same folder as E2E test files and make it available in Cypress UI\n\n\u003e Writing unit test usually help to get 100% code coverage\n\n\u003e More detail about `@vue/test-utils` see [API Docs](https://vue-test-utils.vuejs.org/api/)\n\n## Run test\n\n```\nyarn test:e2e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanumedia%2Fvue-cypress-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanumedia%2Fvue-cypress-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanumedia%2Fvue-cypress-example/lists"}