Skip to content

Commit

Permalink
fix: cypress component testing - fixed vercel#50283
Browse files Browse the repository at this point in the history
  • Loading branch information
ciruz committed May 24, 2023
1 parent 1619a6a commit ce466c7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
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

0 comments on commit ce466c7

Please sign in to comment.