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: cypress component testing - fixes #50283 #50303

Merged
merged 10 commits into from
Jun 14, 2023
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import AboutComponent from './about-component'
/* eslint-disable */
// Disable ESLint to prevent failing linting inside the Next.js repo.
// If you're using ESLint on your project, we recommend installing the ESLint Cypress plugin instead:
// https://github.com/cypress-io/eslint-plugin-cypress

import About from './about'

// Cypress Component Test
describe('<AboutPage />', () => {
describe('<AboutComponent />', () => {
it('should render and display expected content', () => {
// Mount the React component for the About page
cy.mount(<About />)
cy.mount(<AboutComponent />)

// The new page should contain an h1 with "About page"
cy.get('h1').contains('About Page')
Expand Down
14 changes: 14 additions & 0 deletions examples/with-cypress/components/about-component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Link from 'next/link'
import React from 'react'
import styles from '../styles/Home.module.css'

export default function AboutComponent() {
return (
<>
<h1>About Page</h1>
<p className={styles.description}>
<Link href="/">&larr; Go Back</Link>
</p>
</>
)
}
7 changes: 2 additions & 5 deletions examples/with-cypress/pages/about.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import AboutComponent from '../components/about-component'
import styles from '../styles/Home.module.css'
import Link from 'next/link'

export default function About() {
return (
<div className={styles.container}>
<main className={styles.main}>
<h1>About Page</h1>
<p className={styles.description}>
<Link href="/">&larr; Go Back</Link>
</p>
<AboutComponent />
</main>
</div>
)
Expand Down