Skip to content

Commit

Permalink
Merge branch 'canary' into eslint_script_rules
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] committed Aug 10, 2021
2 parents 541e41e + 43393d5 commit b30a937
Show file tree
Hide file tree
Showing 53 changed files with 606 additions and 100 deletions.
15 changes: 14 additions & 1 deletion contributing.md
Expand Up @@ -12,7 +12,20 @@ Read about our [Commitment to Open Source](https://vercel.com/oss).

> You may need to run `yarn types` again if your types get outdated.
To contribute to [our examples](examples), take a look at the [“Adding examples” section](#adding-examples).
To contribute to [our examples](examples), take a look at the [“Adding examples”
section](#adding-examples).

## Building

You can build the project, including all type definitions, with:

```bash
yarn build
# - or -
yarn prepublish
```

If you need to clean the project for any reason, use `yarn clean`.

## Adding warning/error descriptions

Expand Down
2 changes: 1 addition & 1 deletion docs/routing/dynamic-routes.md
Expand Up @@ -145,7 +145,7 @@ For more information on what to do next, we recommend the following sections:

<div class="card">
<a href="/docs/api-reference/next/link.md">
<b>Pages:</b>
<b>next/link:</b>
<small>Enable client-side transitions with next/link.</small>
</a>
</div>
Expand Down
34 changes: 34 additions & 0 deletions examples/with-cypress/.gitignore
@@ -0,0 +1,34 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel
27 changes: 27 additions & 0 deletions examples/with-cypress/README.md
@@ -0,0 +1,27 @@
# Next.js + Cypress

This example shows how to configure Cypress to work with Next.js.

## Preview

Preview the example live on [StackBlitz](http://stackblitz.com/):

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/with-cypress)

## Deploy your own

Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-cypress&project-name=with-cypress&repository-name=with-cypress)

## How to use

Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:

```bash
npx create-next-app --example with-cypress with-cypress-app
# or
yarn create next-app --example with-cypress with-cypress-app
```

Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
3 changes: 3 additions & 0 deletions examples/with-cypress/cypress.json
@@ -0,0 +1,3 @@
{
"baseUrl": "http://localhost:3000"
}
5 changes: 5 additions & 0 deletions examples/with-cypress/cypress/fixtures/example.json
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
20 changes: 20 additions & 0 deletions examples/with-cypress/cypress/integration/app.spec.js
@@ -0,0 +1,20 @@
/* 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

describe('Navigation', () => {
it('should navigate to the about page', () => {
// Start from the index page
cy.visit('http://localhost:3000/')

// Find a link with an href attribute containing "about" and click it
cy.get('a[href*="about"]').click()

// The new url should include "/about"
cy.url().should('include', '/about')

// The new page should contain an h1 with "About page"
cy.get('h1').contains('About Page')
})
})
22 changes: 22 additions & 0 deletions examples/with-cypress/cypress/plugins/index.js
@@ -0,0 +1,22 @@
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

/**
* @type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
25 changes: 25 additions & 0 deletions examples/with-cypress/cypress/support/commands.js
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
20 changes: 20 additions & 0 deletions examples/with-cypress/cypress/support/index.js
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
23 changes: 23 additions & 0 deletions examples/with-cypress/package.json
@@ -0,0 +1,23 @@
{
"name": "with-cypress",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"cypress": "cypress open",
"cypress:headless": "cypress run",
"e2e": "start-server-and-test dev http://localhost:3000 cypress",
"e2e:headless": "start-server-and-test dev http://localhost:3000 cypress:headless"
},
"dependencies": {
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"cypress": "8.2.0",
"start-server-and-test": "1.13.1"
}
}
7 changes: 7 additions & 0 deletions examples/with-cypress/pages/_app.js
@@ -0,0 +1,7 @@
import '../styles/globals.css'

function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}

export default MyApp
17 changes: 17 additions & 0 deletions examples/with-cypress/pages/about.js
@@ -0,0 +1,17 @@
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="/">
<a>&larr; Go Back</a>
</Link>
</p>
</main>
</div>
)
}
77 changes: 77 additions & 0 deletions examples/with-cypress/pages/index.js
@@ -0,0 +1,77 @@
import Head from 'next/head'
import Image from 'next/image'
import Link from 'next/link'
import styles from '../styles/Home.module.css'

export default function Home() {
return (
<div className={styles.container}>
<Head>
<title>Create Next App</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>

<main className={styles.main}>
<h1 className={styles.title}>
Welcome to <a href="https://nextjs.org">Next.js!</a>
</h1>

<p className={styles.description}>
Get started by editing{' '}
<code className={styles.code}>pages/index.js</code>
</p>

<div className={styles.grid}>
<Link href="/about">
<a className={styles.card}>
<h2>About Page &rarr;</h2>
<p>Cypress will test if this link is working.</p>
</a>
</Link>

<a href="https://nextjs.org/docs" className={styles.card}>
<h2>Documentation &rarr;</h2>
<p>Find in-depth information about Next.js features and API.</p>
</a>

<a href="https://nextjs.org/learn" className={styles.card}>
<h2>Learn &rarr;</h2>
<p>Learn about Next.js in an interactive course with quizzes!</p>
</a>

<a
href="https://github.com/vercel/next.js/tree/master/examples"
className={styles.card}
>
<h2>Examples &rarr;</h2>
<p>Discover and deploy boilerplate example Next.js projects.</p>
</a>

<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
className={styles.card}
>
<h2>Deploy &rarr;</h2>
<p>
Instantly deploy your Next.js site to a public URL with Vercel.
</p>
</a>
</div>
</main>

<footer className={styles.footer}>
<a
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Powered by{' '}
<span className={styles.logo}>
<Image src="/vercel.svg" alt="Vercel Logo" width={72} height={16} />
</span>
</a>
</footer>
</div>
)
}
Binary file added examples/with-cypress/public/favicon.ico
Binary file not shown.
4 changes: 4 additions & 0 deletions examples/with-cypress/public/vercel.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b30a937

Please sign in to comment.