Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Cypress to v10 #4929

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ parserOptions:
- src/tsconfig.ce.json
- src/tsconfig.ee.json
- src/tsconfig.spec.json
- cypress/tsconfig.e2e.json
- cypress/tsconfig.json
sourceType: module
extends:
- "./node_modules/gts/"
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ cypress/screenshots
cypress/videos
cypress/plugins/index.js
cypress/plugins/cy-ts-preprocessor.js
cypress/tsconfig.json

# GO
/vendor
87 changes: 87 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright 2022 The Kubermatic Kubernetes Platform contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import {defineConfig} from 'cypress';
import failFast from 'cypress-fail-fast/plugin';
import {deleteAsync} from 'del';

function runnableTestsRegex(...fileName: string[]): string {
return `cypress/e2e/**/!(${fileName.reduce((prevName, name) => `${prevName}|${name}`)}).spec.ts`;
}

export default defineConfig({
chromeWebSecurity: false,
screenshotOnRunFailure: true,
videoCompression: false,
pageLoadTimeout: 60000,
defaultCommandTimeout: 60000,
responseTimeout: 60000,
requestTimeout: 60000,
viewportHeight: 1080,
viewportWidth: 1920,
projectId: 'mdsuba',
video: true,
e2e: {
setupNodeEvents(on, config) {
const isAPIMocked = config.env.MOCKS === 'true' || config.env.MOCKS === true;
const isEnterpriseEdition = config.env.KUBERMATIC_EDITION === 'ee';
// TODO: Update once more tests are rewritten
// const ignored: string[] = ['cypress/**/!(service-accounts|ssh-keys).spec.ts'];
const ignored: string[] = [
runnableTestsRegex('service-accounts', 'ssh-keys', 'edition', 'members', 'defaults', 'dynamic-datacenters'),
];

// if (isAPIMocked) {
// // TODO: Remove it after configuring mocks.
// ignored = ['cypress/**/e2e/stories/opa.spec.ts'];
// } else {
// // TODO: Remove it after fixing flaky tests.
// ignored = [
// 'cypress/**/e2e/providers/anexia.spec.ts',
// 'cypress/**/e2e/providers/equinix.spec.ts',
// 'cypress/**/e2e/providers/vsphere.spec.ts',
// 'cypress/**/e2e/stories/opa.spec.ts',
// 'cypress/**/e2e/stories/admin-settings/administrators.spec.ts',
// ];
// }

// Test providers only in enterprise edition.
// if (!isEnterpriseEdition) {
// ignored = ['cypress/**/e2e/providers/**', ...ignored];
// }

/* eslint-disable no-console */
console.log('mocks: ' + isAPIMocked);
console.log('enterprise edition: ' + isEnterpriseEdition);
console.log('ignored: ' + ignored);
/* eslint-enable no-console */

config.excludeSpecPattern = ignored;

// Remove videos of successful tests and keep only failed ones.
// @ts-ignore
on('after:spec', (_, results) => {
if (results.stats.failures === 0 && results.video) {
return deleteAsync(results.video);
}
});

failFast(on, config);
return config;
},
baseUrl: 'http://localhost:8000',
specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}',
supportFile: 'cypress/support/e2e.ts',
},
});
15 changes: 0 additions & 15 deletions cypress.json

This file was deleted.

43 changes: 0 additions & 43 deletions cypress/plugins/cy-ts-preprocessor.ts

This file was deleted.

78 changes: 0 additions & 78 deletions cypress/plugins/index.ts

This file was deleted.

File renamed without changes.
2 changes: 2 additions & 0 deletions cypress/tsconfig.e2e.json → cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"target": "ES2019",
"strict": true,
"baseUrl": "./",
"paths": {
Expand All @@ -15,5 +16,6 @@
},
"include": [
"**/*.ts",
"../cypress.config.ts"
]
}
Loading