8

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?

crisis.sheep
  • 389
  • 4
  • 15
  • This doesn't cover Vue specifically, but feels very relevant. https://kentcdodds.com/blog/unit-vs-integration-vs-e2e-tests and with Cypress starting to do unit/component level testing too the use-case for jest tests is definitely shrinking in my mind. – aeischeid Apr 01 '21 at 15:33

1 Answers1

3

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

kuceb
  • 16,573
  • 7
  • 42
  • 56
  • Ah, gotcha. I see that Cypress has started working on snapshot testing, but it's still early days. And I see the Cypress devs' point about the dubious usefulness of code coverage, but I do still like the metric as a broad heuristic. I think I will keep Jest around :) Thanks! – crisis.sheep Feb 20 '19 at 07:31