Skip to content

Latest commit

 

History

History

Component Testing with Cypress

End-to-end testing of next.js components using Cypress.

Setup

  1. In a Next.js project, we install the cypress package.

  2. Add the test script to package.json.

  3. Create cypress.config.ts to the root directory with the right configurations for component testing.

  4. Create cypress/support/component.ts file, which contains test setups and other global declarations that need to be run before running the tests.

  5. Create cypress/support/component-index.html to host the components to be tested.

  6. Add cypress tests.

  7. Test the application.

    npm install
    npm run test

Reference