Skip to content

Commit

Permalink
chore(examples): Convert with-cypress example to TypeScript (#38818)
Browse files Browse the repository at this point in the history
- Update `with-cypress` example dependencies;
- Convert `with-cypress` example to TypeScript as suggested in the Contribution docs.


## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
  • Loading branch information
amorimr committed Jul 21, 2022
1 parent 90bbac4 commit 552620f
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 32 deletions.
3 changes: 3 additions & 0 deletions examples/with-cypress/.gitignore
Expand Up @@ -32,3 +32,6 @@ yarn-error.log*

# vercel
.vercel

# typescript
*.tsbuildinfo
7 changes: 7 additions & 0 deletions examples/with-cypress/cypress.config.ts
@@ -0,0 +1,7 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
},
})
3 changes: 0 additions & 3 deletions examples/with-cypress/cypress.json

This file was deleted.

File renamed without changes.
22 changes: 0 additions & 22 deletions examples/with-cypress/cypress/plugins/index.js

This file was deleted.

@@ -1,5 +1,6 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.js shows you how to
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
Expand All @@ -23,3 +24,14 @@
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
@@ -1,5 +1,5 @@
// ***********************************************************
// This example support/index.js is processed and
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
Expand Down
8 changes: 8 additions & 0 deletions examples/with-cypress/cypress/tsconfig.json
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "node"]
},
"include": ["**/*.ts"]
}
5 changes: 5 additions & 0 deletions examples/with-cypress/next-env.d.ts
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
12 changes: 8 additions & 4 deletions examples/with-cypress/package.json
Expand Up @@ -11,11 +11,15 @@
},
"dependencies": {
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2"
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"cypress": "8.2.0",
"start-server-and-test": "1.13.1"
"@types/node": "18.0.6",
"@types/react": "18.0.15",
"@types/react-dom": "18.0.6",
"cypress": "10.3.1",
"start-server-and-test": "1.14.0",
"typescript": "4.7.4"
}
}
@@ -1,6 +1,7 @@
import type { AppProps } from 'next/app'
import '../styles/globals.css'

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

Expand Down
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions examples/with-cypress/tsconfig.json
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}

0 comments on commit 552620f

Please sign in to comment.