Skip to content

Commit 552620f

Browse files
authored
chore(examples): Convert with-cypress example to TypeScript (vercel#38818)
- 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)
1 parent 90bbac4 commit 552620f

File tree

14 files changed

+67
-32
lines changed

14 files changed

+67
-32
lines changed

examples/with-cypress/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ yarn-error.log*
3232

3333
# vercel
3434
.vercel
35+
36+
# typescript
37+
*.tsbuildinfo
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const { defineConfig } = require('cypress')
2+
3+
module.exports = defineConfig({
4+
e2e: {
5+
baseUrl: 'http://localhost:3000',
6+
},
7+
})

examples/with-cypress/cypress.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/with-cypress/cypress/plugins/index.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/with-cypress/cypress/support/commands.js renamed to examples/with-cypress/cypress/support/commands.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
/// <reference types="cypress" />
12
// ***********************************************
2-
// This example commands.js shows you how to
3+
// This example commands.ts shows you how to
34
// create various custom commands and overwrite
45
// existing commands.
56
//
@@ -23,3 +24,14 @@
2324
//
2425
// -- This will overwrite an existing command --
2526
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
27+
//
28+
// declare global {
29+
// namespace Cypress {
30+
// interface Chainable {
31+
// login(email: string, password: string): Chainable<void>
32+
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
33+
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
34+
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
35+
// }
36+
// }
37+
// }

examples/with-cypress/cypress/support/index.js renamed to examples/with-cypress/cypress/support/e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ***********************************************************
2-
// This example support/index.js is processed and
2+
// This example support/e2e.ts is processed and
33
// loaded automatically before your test files.
44
//
55
// This is a great place to put global configuration and
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"lib": ["es5", "dom"],
5+
"types": ["cypress", "node"]
6+
},
7+
"include": ["**/*.ts"]
8+
}

examples/with-cypress/next-env.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.

examples/with-cypress/package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@
1111
},
1212
"dependencies": {
1313
"next": "latest",
14-
"react": "17.0.2",
15-
"react-dom": "17.0.2"
14+
"react": "18.2.0",
15+
"react-dom": "18.2.0"
1616
},
1717
"devDependencies": {
18-
"cypress": "8.2.0",
19-
"start-server-and-test": "1.13.1"
18+
"@types/node": "18.0.6",
19+
"@types/react": "18.0.15",
20+
"@types/react-dom": "18.0.6",
21+
"cypress": "10.3.1",
22+
"start-server-and-test": "1.14.0",
23+
"typescript": "4.7.4"
2024
}
2125
}

0 commit comments

Comments
 (0)