Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need a unit-testing framework if I'm already using Cypress in a Vue.js app?

When scaffolding a new project with the Vue.js CLI, it offers a choice of both unit-testing and E2E-testing frameworks.

Unit-testing functionality is perfectly adequate in Cypress. My question, then: is there an advantage to using a distinct unit-testing framework if I'm already using Cypress?

like image 291
crisis.sheep Avatar asked Feb 19 '19 10:02

crisis.sheep


People also ask

Does Cypress do unit testing?

Cypress is an open source end-to-end testing framework that can help you unify web application testing. It works for all programming languages, platforms, and browsers. You can use Cypress for unit and integration testing. All tests are written in JavaScript and run in real browsers.

Which testing framework is best for Vue?

Vue does not have a specific testing framework of its own, but most people are using Jest as their unit testing framework of choice. It has an easy to remember API, flexible assertion mechanics and with a large community behind it, you can find many plugins and solutions to common problems.

Should you use Jest and Cypress together?

short answers: It's very common to use Jest and Cypress in the same codebase. With component Libraries like Vue and React, the line between integration and unit tests can get a bit fuzzy.

Which is better Jest or cypress?

As a result Cypress provides better, faster, and more reliable testing for anything that runs in a browser. Cypress works on any front-end framework or website. What is Jest? Painless JavaScript Unit Testing.


1 Answers

There is a third-party adapter made by a Cypress contributor here called cypress-vue-unit-test(along with unit-test adapters for other popular frameworks).

You should check that out and see if it meets your needs over, say, Jest

From this tutorial about unit testing vuejs, some Jest advantages over Cypress are:

  • Built in code coverage
  • Snapshot testing
  • Module mocking utilities

Also see repo for vue-test-utils

like image 99
bkucera Avatar answered Sep 29 '22 05:09

bkucera