diff --git a/examples/with-cypress/.gitignore b/examples/with-cypress/.gitignore index 1437c53f70bc..88b6f0d98164 100644 --- a/examples/with-cypress/.gitignore +++ b/examples/with-cypress/.gitignore @@ -32,3 +32,6 @@ yarn-error.log* # vercel .vercel + +# typescript +*.tsbuildinfo diff --git a/examples/with-cypress/cypress.config.ts b/examples/with-cypress/cypress.config.ts new file mode 100644 index 000000000000..b63e356440e3 --- /dev/null +++ b/examples/with-cypress/cypress.config.ts @@ -0,0 +1,7 @@ +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + e2e: { + baseUrl: 'http://localhost:3000', + }, +}) diff --git a/examples/with-cypress/cypress.json b/examples/with-cypress/cypress.json deleted file mode 100644 index 17ef242e711f..000000000000 --- a/examples/with-cypress/cypress.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "baseUrl": "http://localhost:3000" -} diff --git a/examples/with-cypress/cypress/integration/app.spec.js b/examples/with-cypress/cypress/e2e/app.cy.ts similarity index 100% rename from examples/with-cypress/cypress/integration/app.spec.js rename to examples/with-cypress/cypress/e2e/app.cy.ts diff --git a/examples/with-cypress/cypress/plugins/index.js b/examples/with-cypress/cypress/plugins/index.js deleted file mode 100644 index 59b2bab6e4e6..000000000000 --- a/examples/with-cypress/cypress/plugins/index.js +++ /dev/null @@ -1,22 +0,0 @@ -/// -// *********************************************************** -// 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 -} diff --git a/examples/with-cypress/cypress/support/commands.js b/examples/with-cypress/cypress/support/commands.ts similarity index 60% rename from examples/with-cypress/cypress/support/commands.js rename to examples/with-cypress/cypress/support/commands.ts index 119ab03f7cda..95857aea4cdf 100644 --- a/examples/with-cypress/cypress/support/commands.js +++ b/examples/with-cypress/cypress/support/commands.ts @@ -1,5 +1,6 @@ +/// // *********************************************** -// This example commands.js shows you how to +// This example commands.ts shows you how to // create various custom commands and overwrite // existing commands. // @@ -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 +// drag(subject: string, options?: Partial): Chainable +// dismiss(subject: string, options?: Partial): Chainable +// visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable +// } +// } +// } diff --git a/examples/with-cypress/cypress/support/index.js b/examples/with-cypress/cypress/support/e2e.ts similarity index 92% rename from examples/with-cypress/cypress/support/index.js rename to examples/with-cypress/cypress/support/e2e.ts index d68db96df269..ed5730de1148 100644 --- a/examples/with-cypress/cypress/support/index.js +++ b/examples/with-cypress/cypress/support/e2e.ts @@ -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 diff --git a/examples/with-cypress/cypress/tsconfig.json b/examples/with-cypress/cypress/tsconfig.json new file mode 100644 index 000000000000..18edb199acdb --- /dev/null +++ b/examples/with-cypress/cypress/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": ["es5", "dom"], + "types": ["cypress", "node"] + }, + "include": ["**/*.ts"] +} diff --git a/examples/with-cypress/next-env.d.ts b/examples/with-cypress/next-env.d.ts new file mode 100644 index 000000000000..4f11a03dc6cc --- /dev/null +++ b/examples/with-cypress/next-env.d.ts @@ -0,0 +1,5 @@ +/// +/// + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/examples/with-cypress/package.json b/examples/with-cypress/package.json index d277dee94d4a..a3b47a25ac36 100644 --- a/examples/with-cypress/package.json +++ b/examples/with-cypress/package.json @@ -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" } } diff --git a/examples/with-cypress/pages/_app.js b/examples/with-cypress/pages/_app.tsx similarity index 50% rename from examples/with-cypress/pages/_app.js rename to examples/with-cypress/pages/_app.tsx index 1e1cec92425c..c7e1bbcd1aef 100644 --- a/examples/with-cypress/pages/_app.js +++ b/examples/with-cypress/pages/_app.tsx @@ -1,6 +1,7 @@ +import type { AppProps } from 'next/app' import '../styles/globals.css' -function MyApp({ Component, pageProps }) { +function MyApp({ Component, pageProps }: AppProps) { return } diff --git a/examples/with-cypress/pages/about.js b/examples/with-cypress/pages/about.tsx similarity index 100% rename from examples/with-cypress/pages/about.js rename to examples/with-cypress/pages/about.tsx diff --git a/examples/with-cypress/pages/index.js b/examples/with-cypress/pages/index.tsx similarity index 100% rename from examples/with-cypress/pages/index.js rename to examples/with-cypress/pages/index.tsx diff --git a/examples/with-cypress/tsconfig.json b/examples/with-cypress/tsconfig.json new file mode 100644 index 000000000000..b8d597880a1a --- /dev/null +++ b/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"] +}