DEV Community

Cover image for Nextjs + Cypress + Code coverage Setup
LamNVQ
LamNVQ

Posted on

3

Nextjs + Cypress + Code coverage Setup

For quickly understand,

Give a look in my current project:

https://github.com/DawnGate/nextjs-cypress-code-coverage

I struggle with config nextjs + cypress + babel + istanbul for Code coverage in 2 days.

And after research, try and test. I created a public repo for quickly setup a new project, and I want to other can easy to setup.

For quick summary:

  • Create new project with "npm i create-next-app@latest"
  • Install cypress, @cypress/code-coverage, babel-plugin-istanbul
  • Using babel to override the swc compiler (remember remove next/font -> you will find some documents talk about it)
  • Config cypress, babelrc.json, add api/coverage for get coverage data from server-side component of Nextjs (Please read the source code for more information)
  • npx cypress open or npx cypress run => check your coverage report and Done!

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay