Skip to content

Commit

Permalink
Upgraded cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
obgibson committed Apr 26, 2024
1 parent 59fb46a commit 6723857
Show file tree
Hide file tree
Showing 13 changed files with 428 additions and 763 deletions.
11 changes: 11 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from "cypress";

export default defineConfig({
component: {
devServer: {
framework: "create-react-app",
bundler: "webpack",
},
specPattern: "**/*.test.cypress.{js,ts,jsx,tsx}"
},
});
10 changes: 0 additions & 10 deletions cypress.json

This file was deleted.

11 changes: 11 additions & 0 deletions cypress.plugin-api.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from 'cypress';

export default defineConfig({
component: {
devServer: {
framework: 'create-react-app',
bundler: 'webpack',
},
specPattern: 'plugin-api/**/*.test.cypress.{js,ts,jsx,tsx}',
},
});
12 changes: 0 additions & 12 deletions cypress.plugin-api.json

This file was deleted.

11 changes: 11 additions & 0 deletions cypress.plugin-dev.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from 'cypress';

export default defineConfig({
component: {
devServer: {
framework: 'create-react-app',
bundler: 'webpack',
},
specPattern: 'plugin-api/dev/**/*.test.cypress.{js,ts,jsx,tsx}',
},
});
12 changes: 0 additions & 12 deletions cypress.plugin-dev.json

This file was deleted.

1 change: 0 additions & 1 deletion cypress/support/commands.js

This file was deleted.

38 changes: 38 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts 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) => { ... })
//
// 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>
// }
// }
// }
import 'cypress-wait-until';
12 changes: 12 additions & 0 deletions cypress/support/component-index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Components App</title>
</head>
<body>
<div data-cy-root></div>
</body>
</html>
39 changes: 39 additions & 0 deletions cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// ***********************************************************
// This example support/component.ts 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')

import { mount } from 'cypress/react18'

// Augment the Cypress namespace to include type definitions for
// your custom command.
// Alternatively, can be defined in cypress/support/component.d.ts
// with a <reference path="./component" /> at the top of your spec.
declare global {
namespace Cypress {
interface Chainable {
mount: typeof mount
}
}
}

Cypress.Commands.add('mount', mount)

// Example use:
// cy.mount(<MyComponent />)
20 changes: 20 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.ts 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')
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"test": "cypress open-ct",
"test:ci": "cypress run-ct --config watchForFileChanges=false",
"test:pluginapi": "cypress open-ct --config-file ./cypress.plugin-api.json",
"test:pluginapi:ci": "cypress run-ct --config-file ./cypress.plugin-api.json",
"test:ci": "cypress run --component --config watchForFileChanges=false",
"test:pluginapi": "cypress open-ct --config-file ./cypress.plugin-api.config.ts",
"test:pluginapi:ci": "cypress run --component --config-file ./cypress.plugin-api.config.ts",
"lint": "eslint \"./src/**/*.{ts,tsx}\"",
"eject": "react-scripts eject",
"format": "prettier --write src",
"dev:plugin": "concurrently --kill-others --names \"PLUGIN-SERVE,DEV\" -c \"bgBlue.bold,bgMagenta.bold\" \"npm:dev-plugin-serve\" \"npm:dev-plugin-cypress\"",
"dev-plugin-serve": "serve ./plugin-api",
"dev-plugin-cypress": "cypress open-ct --config-file ./cypress.plugin-dev.json"
"dev-plugin-cypress": "cypress open-ct --config-file ./cypress.plugin-dev.config.ts"
},
"browserslist": {
"production": [
Expand All @@ -55,8 +55,8 @@
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@cypress/react": "^5.12.1",
"@cypress/webpack-dev-server": "^1.8.0",
"@cypress/react": "^8.0.0",
"@cypress/webpack-dev-server": "^3.8.0",
"@types/node": "^18.16.3",
"@types/react": "^18.2.5",
"@types/react-dom": "^18.2.3",
Expand All @@ -68,8 +68,8 @@
"@typescript-eslint/parser": "^5.59.2",
"concurrently": "^8.0.1",
"cross-env": "^7.0.3",
"cypress": "^9.3.1",
"cypress-wait-until": "^1.7.1",
"cypress": "^13.8.1",
"cypress-wait-until": "^3.0.1",
"eslint-config-prettier": "^9.1.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-import": "^2.23.3",
Expand Down
Loading

0 comments on commit 6723857

Please sign in to comment.