diff --git a/client/cypress.config.ts b/client/cypress.config.ts new file mode 100644 index 00000000..57fc063d --- /dev/null +++ b/client/cypress.config.ts @@ -0,0 +1,23 @@ +import { defineConfig } from 'cypress' + +export default defineConfig({ + videoUploadOnPasses: false, + reporter: 'junit', + reporterOptions: { + mochaFile: 'cypress/test-reports/frontend/cypress-results-[hash].xml', + toConsole: true, + }, + projectId: 'msk-fe', + retries: { + runMode: 2, + }, + e2e: { + // We've imported your old cypress plugins here. + // You may want to clean this up later by importing these. + setupNodeEvents(on, config) { + return require('./cypress/plugins/index.js')(on, config) + }, + baseUrl: 'http://localhost:8080', + specPattern: 'cypress/integration/frontend/**/*.{js,jsx,ts,tsx}', + }, +}) diff --git a/client/cypress.e2e.ts b/client/cypress.e2e.ts new file mode 100644 index 00000000..32dd7f2c --- /dev/null +++ b/client/cypress.e2e.ts @@ -0,0 +1,15 @@ +import {defineConfig} from 'cypress'; +export default defineConfig( { + e2e: { + "baseUrl": "http://localhost:8000", + specPattern: 'cypress/e2e/e2e/**/*.{spec,cy}.{js,ts}', + supportFile: 'cypress/support/e2e.js', + }, + "videoUploadOnPasses": false, + "reporter": "junit", + "reporterOptions": { + "mochaFile": "cypress/test-reports/e2e/cypress-results-[hash].xml", + "toConsole": true + }, + "projectId": "msk-ee", +}); diff --git a/client/cypress.frontend.config.ts b/client/cypress.frontend.config.ts new file mode 100644 index 00000000..57fc063d --- /dev/null +++ b/client/cypress.frontend.config.ts @@ -0,0 +1,23 @@ +import { defineConfig } from 'cypress' + +export default defineConfig({ + videoUploadOnPasses: false, + reporter: 'junit', + reporterOptions: { + mochaFile: 'cypress/test-reports/frontend/cypress-results-[hash].xml', + toConsole: true, + }, + projectId: 'msk-fe', + retries: { + runMode: 2, + }, + e2e: { + // We've imported your old cypress plugins here. + // You may want to clean this up later by importing these. + setupNodeEvents(on, config) { + return require('./cypress/plugins/index.js')(on, config) + }, + baseUrl: 'http://localhost:8080', + specPattern: 'cypress/integration/frontend/**/*.{js,jsx,ts,tsx}', + }, +}) diff --git a/client/cypress.frontend.json b/client/cypress.frontend.json deleted file mode 100644 index e1180303..00000000 --- a/client/cypress.frontend.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "baseUrl": "http://localhost:8080", - "videoUploadOnPasses": false, - "reporter": "junit", - "reporterOptions": { - "mochaFile": "cypress/test-reports/frontend/cypress-results-[hash].xml", - "toConsole": true - }, - "projectId": "msk-fe", - "integrationFolder": "cypress/integration/frontend", - "$schema": "https://on.cypress.io/cypress.schema.json", - "retries": { - "runMode": 2 - } -} diff --git a/client/cypress.frontend.ts b/client/cypress.frontend.ts new file mode 100644 index 00000000..42bbeedc --- /dev/null +++ b/client/cypress.frontend.ts @@ -0,0 +1,34 @@ +import {defineConfig} from 'cypress'; +import {readFileSync} from "fs"; +import {resolve} from "path"; + +export default defineConfig({ + chromeWebSecurity: false, + e2e: { + baseUrl: "http://localhost:8080", + specPattern: 'cypress/e2e/frontend/**/*.spec.{js,ts}', + supportFile: 'cypress/support/e2e.js', + setupNodeEvents(on, config) { + on('task', { + getSchema() { + return readFileSync( + resolve(__dirname, '../server/schema.graphql'), + 'utf8' + ); + } + }); + }, + }, + videoUploadOnPasses: false, + reporter: "junit", + reporterOptions: { + mochaFile: "cypress/test-reports/frontend/cypress-results-[hash].xml", + toConsole: true + }, + "projectId": "msk-fe", + retries: { + runMode: 3 + } +}); + + diff --git a/client/cypress/support/commands.js b/client/cypress/support/commands.js index 29bb00de..0089cfa2 100644 --- a/client/cypress/support/commands.js +++ b/client/cypress/support/commands.js @@ -89,14 +89,6 @@ Cypress.Commands.add('startGraphQLCapture', () => { cy.route('POST', '/api/graphql/').as('graphQL'); }); -// from https://stackoverflow.com/questions/53814647/how-can-i-alias-specific-graphql-requests-in-cypress -Cypress.Commands.add('waitFor', operationName => { - cy.wait('@graphQL').then(({request}) => { - if (request.body.operationName !== operationName) { - return cy.waitFor(operationName); - } - }); -}); Cypress.Commands.add('changePassword', (oldPassword, newPassword) => { if (oldPassword) { diff --git a/client/cypress/support/index.js b/client/cypress/support/index.js deleted file mode 100644 index 060da8fc..00000000 --- a/client/cypress/support/index.js +++ /dev/null @@ -1,26 +0,0 @@ -// *********************************************************** -// 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') - -// from https://stackoverflow.com/questions/49079005/how-to-stub-a-call-to-graphql-using-cypress#49088084 -// Cypress.on('window:before:load', win => { -// win.fetch = null; -// win.Blob = null; -// }); diff --git a/client/package.json b/client/package.json index b35b3e21..16e7a0a1 100644 --- a/client/package.json +++ b/client/package.json @@ -15,10 +15,10 @@ "open:cypress:frontend": "npm run cypress:frontend:open", "test:cypress:e2e": "npm run cypress:e2e:test", "test:cypress:frontend": "npm run cypress:frontend:test", - "cypress:e2e:open": "cypress open --config-file cypress.e2e.json", - "cypress:frontend:open": "cypress open --config-file cypress.frontend.json", - "cypress:e2e:test": "cypress run --config-file cypress.e2e.json", - "cypress:frontend:test": "cypress run --config-file cypress.frontend.json", + "cypress:e2e:open": "cypress open --config-file cypress.e2e.ts", + "cypress:frontend:open": "cypress open --config-file cypress.frontend.ts", + "cypress:e2e:test": "cypress run --config-file cypress.e2e.ts", + "cypress:frontend:test": "cypress run --config-file cypress.frontend.ts", "install:cypress": "cypress install", "test:unit": "jest", "cypress:parallel": "CYPRESS_API_URL=\"https://iterativ-cypress-director.herokuapp.com/\" cy2 run --parallel --record --key somekey --config-file cypress.frontend.json --ci-build-id some-id", @@ -62,7 +62,7 @@ "css-loader": "^0.28.0", "css-minimizer-webpack-plugin": "^3.4.1", "cy2": "^1.2.1", - "cypress": "^9.5.0", + "cypress": "^10", "dayjs": "^1.10.7", "debounce": "^1.2.0", "eslint": "^7.32.0",