Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nextjs): Adding styles to nextjs cypress should not fail. #22170

Merged
merged 1 commit into from Mar 5, 2024

Conversation

ndcunningham
Copy link
Contributor

When testing nextjs components with cypress we need to update the html to include styles added by Next.js

RE: https://github.com/cypress-io/cypress-component-testing-apps/blob/main/react-next13-ts/cypress/support/component-index.html

import { mount } from 'cypress/react18';
import './styles.ct.css'; // <--------- Here

import './commands';

// add component testing only related command here, such as mount
declare global {
  // eslint-disable-next-line @typescript-eslint/no-namespace
  namespace Cypress {
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    interface Chainable<Subject> {
      mount: typeof mount;
    }
  }
}

Cypress.Commands.add('mount', mount);

Also added a test case for Router from next/router to show that server component testing works.

async server component testing is not yet defined from RSC see: testing-library/react-testing-library#1209
Hence, these test cases are not generated.

closes: #21768

@ndcunningham ndcunningham added the scope: nextjs Issues related to NextJS support for Nx label Mar 5, 2024
@ndcunningham ndcunningham self-assigned this Mar 5, 2024
@ndcunningham ndcunningham requested review from a team as code owners March 5, 2024 18:52
Copy link

vercel bot commented Mar 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Mar 5, 2024 9:53pm

@ndcunningham ndcunningham force-pushed the fix/nextjs-component-cypress-config branch from a3c434b to 6cf8024 Compare March 5, 2024 21:52
@ndcunningham ndcunningham merged commit 391f3ab into master Mar 5, 2024
6 checks passed
@ndcunningham ndcunningham deleted the fix/nextjs-component-cypress-config branch March 5, 2024 22:17
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
scope: nextjs Issues related to NextJS support for Nx
Projects
None yet
2 participants