GithubHelp home page GithubHelp logo

kylemh / next-ts-with-cypress-coverage Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 9.0 404 KB

An example create-next-app project using TypeScript, Cypress, @testing-library/cypress, and instrumented coverage

TypeScript 82.94% JavaScript 1.18% CSS 15.88%
cypress nextjs istanbul typescript testing-library

next-ts-with-cypress-coverage's Introduction

This is a Next.js project bootstrapped with create-next-app for the express purpose of demonstrating Next.js, TypeScript, and Cypress working together with working coverage reports.

Older Versions

You can see an example that should work with any combination of Next.js 9 thru 12 and Cypress 5 thru 9 here.

Contributing

Instructions on how to get started with this repo are below. Contributions we would love to receive:

  • An example without Babel. This would use the SWC Coverage Plugin. The current examples all have a slower build, slower dev server, and slower hot reload than Next.js applications that DONT use Babel.
  • An example using Next.js's App Directory and providing coverage for server components.
  • Use GitHub Actions to prove that coverage is outputting so that people can freely contribute without manual review on their branch.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev

Open http://localhost:3000 with your browser to see the result.

Then open the Cypress test runner:

npm run cypress open
# or
yarn cypress open

The Proof

To see coverage, yarn build && yarn start followed with a separate yarn cypress run. Once finished, yarn see-cy-coverage.

Screenshot of coverage report

next-ts-with-cypress-coverage's People

Contributors

kylemh avatar nandosangenetto avatar warizz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

next-ts-with-cypress-coverage's Issues

nextjs-types.d.ts is duplicated

The @types/nextjs-types.d.ts file already exists in /next-env.d.ts

Thank for you for work. Are you able to update to next 12?

Server-side coverage is not tracked

Hey!

Thanks for putting this together, I was able to adopt it for my project ❤️

However, I found that some files don't seem to be tracked, specifically anything that runs server-side. In my project, I have middlewares, api routes, getServerSideProps, etc... and all of that is not being tracked.

I've put together a minimum example with a single getServerSideProps call.

I made sure to explicitly include the file I want to cover in the .nycrc.json file, however, code in no-coverage-here is not being tracked as you can see:

image

An interesting side note seems to be, that there invocation of foo() seems to be tracked correctly, it's really just the file inside no-coverage-here that's missing.
image

Any idea what could be going wrong here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.