Downgrade Cypress to 13.6.2 (#183047)

## Summary

We noticed some instability in Cypress in current version, downgrading
seems to be solving the issue.
This commit is contained in:
Patryk Kopyciński 2024-05-14 16:04:23 +02:00 committed by GitHub
parent deceef9976
commit 13db1c9b21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
44 changed files with 85 additions and 398 deletions

View file

@ -81,7 +81,7 @@ steps:
preemptible: true
depends_on: build
timeout_in_minutes: 60
parallelism: 2
parallelism: 3
retry:
automatic:
- exit_status: '-1'
@ -149,7 +149,7 @@ steps:
preemptible: true
depends_on: build
timeout_in_minutes: 60
parallelism: 2
parallelism: 1
retry:
automatic:
- exit_status: '-1'

View file

@ -100,7 +100,7 @@ steps:
- build
- quick_checks
timeout_in_minutes: 60
parallelism: 2
parallelism: 3
retry:
automatic:
- exit_status: '-1'
@ -156,7 +156,7 @@ steps:
- build
- quick_checks
timeout_in_minutes: 60
parallelism: 2
parallelism: 1
retry:
automatic:
- exit_status: '-1'
@ -296,7 +296,7 @@ steps:
- build
- quick_checks
timeout_in_minutes: 60
parallelism: 3
parallelism: 2
retry:
automatic:
- exit_status: '-1'
@ -310,7 +310,7 @@ steps:
- build
- quick_checks
timeout_in_minutes: 60
parallelism: 7
parallelism: 6
retry:
automatic:
- exit_status: '-1'

View file

@ -7,7 +7,7 @@ steps:
- build
- quick_checks
timeout_in_minutes: 60
parallelism: 2
parallelism: 3
retry:
automatic:
- exit_status: '-1'

View file

@ -7,7 +7,7 @@ steps:
- build
- quick_checks
timeout_in_minutes: 60
parallelism: 3
parallelism: 2
retry:
automatic:
- exit_status: '-1'

View file

@ -21,7 +21,7 @@ steps:
- build
- quick_checks
timeout_in_minutes: 60
parallelism: 7
parallelism: 8
retry:
automatic:
- exit_status: '-1'

View file

@ -21,7 +21,7 @@ steps:
- build
- quick_checks
timeout_in_minutes: 60
parallelism: 2
parallelism: 1
retry:
automatic:
- exit_status: '-1'

View file

@ -10,7 +10,6 @@ fi
source .buildkite/scripts/common/util.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
.buildkite/scripts/bootstrap.sh
export JOB=kibana-defend-workflows-serverless-cypress

View file

@ -9,7 +9,6 @@ if [ -z "$1" ]
fi
source .buildkite/scripts/common/util.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
.buildkite/scripts/bootstrap.sh
export JOB=kibana-security-solution-chrome

View file

@ -1,4 +0,0 @@
#!/usr/bin/env bash
Xvfb -screen 0 1680x946x24 :99 &
export DISPLAY=:99

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-defend-workflows-cypress
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/plugins/security_solution
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci defend-workflows-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:dw:run; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:dw:run; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
.buildkite/scripts/bootstrap.sh
node scripts/build_kibana_platform_plugins.js

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-defend-workflows-serverless-cypress
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/plugins/security_solution
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci defend-workflows-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:dw:serverless:run; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:dw:serverless:run; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
.buildkite/scripts/bootstrap.sh
node scripts/build_kibana_platform_plugins.js

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-fleet-cypress
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
# TODO: remove the line below to use build artifacts for tests.
# in addition to remove the line, we will have to expose the kibana install dir into the downloaded build location

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/common/util.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
.buildkite/scripts/bootstrap.sh
node scripts/build_kibana_platform_plugins.js
@ -14,4 +13,4 @@ buildkite-agent meta-data set "${BUILDKITE_JOB_ID}_is_test_execution_step" 'fals
echo "--- Osquery Cypress tests, burning changed specs (Chrome)"
yarn --cwd x-pack/plugins/osquery cypress:changed-specs-only
yarn --cwd x-pack/plugins/osquery cypress:changed-specs-only

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/test/security_solution_cypress
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci sec-sol-cypress-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:ai_assistant:run:serverless; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:ai_assistant:run:serverless; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}

View file

@ -3,11 +3,10 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-serverless-security-cypress
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
echo "--- Security Defend Workflows Serverless Cypress"
yarn --cwd x-pack/test_serverless/functional/test_suites/security/cypress cypress:run
yarn --cwd x-pack/test_serverless/functional/test_suites/security/cypress cypress:run

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/test/security_solution_cypress
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci sec-sol-cypress-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:detection_engine:run:serverless; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:detection_engine:run:serverless; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/test/security_solution_cypress
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci sec-sol-cypress-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:detection_engine:exceptions:run:serverless; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:detection_engine:exceptions:run:serverless; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-serverless-security-cypress
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/test/security_solution_cypress
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci sec-sol-cypress-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:entity_analytics:run:serverless; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:entity_analytics:run:serverless; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/test/security_solution_cypress
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci sec-sol-cypress-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:explore:run:serverless; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:explore:run:serverless; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/test/security_solution_cypress
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci sec-sol-cypress-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:investigations:run:serverless; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:investigations:run:serverless; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
# TODO: remove the line below to use build artifacts for tests.
# in addition to remove the line, we will have to expose the kibana install dir into the downloaded build location

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/test/security_solution_cypress
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci sec-sol-cypress-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:rule_management:run:serverless; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:rule_management:run:serverless; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/test/security_solution_cypress
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci sec-sol-cypress-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:rule_management:prebuilt_rules:run:serverless; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:rule_management:prebuilt_rules:run:serverless; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/test/security_solution_cypress
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci sec-sol-cypress-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:ai_assistant:run:ess; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:ai_assistant:run:ess; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/test/security_solution_cypress
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci sec-sol-cypress-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:detection_engine:run:ess; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:detection_engine:run:ess; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/test/security_solution_cypress
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci sec-sol-cypress-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:detection_engine:exceptions:run:ess; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:detection_engine:exceptions:run:ess; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/test/security_solution_cypress
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci sec-sol-cypress-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:entity_analytics:run:ess; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:entity_analytics:run:ess; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/test/security_solution_cypress
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci sec-sol-cypress-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:explore:run:ess; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:explore:run:ess; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/test/security_solution_cypress
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci sec-sol-cypress-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:investigations:run:ess; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:investigations:run:ess; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/test/security_solution_cypress
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci sec-sol-cypress-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:rule_management:run:ess; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:rule_management:run:ess; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-security-solution-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -15,4 +14,4 @@ cd x-pack/test/security_solution_cypress
set +e
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci sec-sol-cypress-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:rule_management:prebuilt_rules:run:ess; status=$?; yarn junit:merge || :; exit $status
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn cypress:rule_management:prebuilt_rules:run:ess; status=$?; yarn junit:merge || :; exit $status

View file

@ -3,7 +3,6 @@
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/functional/common_cypress.sh
export JOB=kibana-threat-intelligence-chrome
export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION}
@ -12,4 +11,4 @@ echo "--- Threat Intelligence Cypress tests (Chrome)"
BK_ANALYTICS_API_KEY=$(vault_get security-solution-ci threat-intelligence-bk-api-key)
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn --cwd x-pack/plugins/threat_intelligence cypress:run
BK_ANALYTICS_API_KEY=$BK_ANALYTICS_API_KEY yarn --cwd x-pack/plugins/threat_intelligence cypress:run

View file

@ -1214,7 +1214,6 @@
"@babel/types": "7.21.2",
"@bazel/ibazel": "^0.16.2",
"@bazel/typescript": "4.6.2",
"@cypress/code-coverage": "^3.12.18",
"@cypress/grep": "^4.0.1",
"@cypress/webpack-preprocessor": "^6.0.1",
"@elastic/eslint-plugin-eui": "0.0.2",
@ -1582,7 +1581,7 @@
"cssnano": "^5.1.12",
"cssnano-preset-default": "^5.2.12",
"csstype": "^3.0.2",
"cypress": "^13.6.3",
"cypress": "13.6.2",
"cypress-axe": "^1.5.0",
"cypress-file-upload": "^5.0.8",
"cypress-multi-reporters": "^1.6.4",

View file

@ -27,8 +27,6 @@
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-explicit-any
module.exports = (on: any, config: any) => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('@cypress/code-coverage/task')(on, config);
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('@cypress/grep/src/plugin')(config);

View file

@ -1,277 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
/* eslint-disable prettier/prettier,no-console,@typescript-eslint/ban-ts-comment,@typescript-eslint/no-var-requires,import/no-extraneous-dependencies,padding-line-between-statements */
// / <reference types="cypress" />
// @ts-check
// TODO: we should be able to remove this ts-ignore while using isolatedModules
// this is a skip for the errors created when typechecking with isolatedModules
// @ts-ignore
const dayjs = require('dayjs');
const duration = require('dayjs/plugin/duration');
// const { filterSpecsFromCoverage } = require('./support-utils');
dayjs.extend(duration);
/**
* Sends collected code coverage object to the backend code
* via "cy.task".
*/
const sendCoverage = (coverage: any, pathname = '/') => {
logMessage(`Saving code coverage for **${pathname}**`);
// const withoutSpecs = filterSpecsFromCoverage(coverage);
const appCoverageOnly = filterSupportFilesFromCoverage(coverage);
// stringify coverage object for speed
cy.task('combineCoverage', JSON.stringify(appCoverageOnly), {
log: false,
});
};
/**
* Consistently logs the given string to the Command Log
* so the user knows the log message is coming from this plugin.
* @param {string} s Message to log.
*/
const logMessage = (s: string) => {
cy.log(`${s} \`[@cypress/code-coverage]\``);
};
/**
* Removes support file from the coverage object.
* If there are more files loaded from support folder, also removes them
*/
const filterSupportFilesFromCoverage = (totalCoverage: any) => {
// @ts-expect-error update types
const integrationFolder = Cypress.config('e2eFolder');
const supportFile = Cypress.config('supportFile');
/** @type {string} Cypress run-time config has the support folder string */
// @ts-ignore
const supportFolder = Cypress.config('supportFolder');
const isSupportFile = (filename: string) => filename === supportFile;
let coverage = Cypress._.omitBy(totalCoverage, (fileCoverage, filename) =>
isSupportFile(filename)
);
// check the edge case
// if we have files from support folder AND the support folder is not same
// as the integration, or its prefix (this might remove all app source files)
// then remove all files from the support folder
// @ts-expect-error update types
if (!integrationFolder.startsWith(supportFolder)) {
// remove all covered files from support folder
coverage = Cypress._.omitBy(totalCoverage, (fileCoverage, filename) =>
filename.startsWith(supportFolder)
);
}
return coverage;
};
const registerHooks = () => {
let windowCoverageObjects: any[];
const hasE2ECoverage = () => Boolean(windowCoverageObjects.length);
// @ts-ignore
const hasUnitTestCoverage = () => Boolean(window.__coverage__);
before(() => {
// we need to reset the coverage when running
// in the interactive mode, otherwise the counters will
// keep increasing every time we rerun the tests
const logInstance = Cypress.log({
name: 'Coverage',
message: ['Reset [@cypress/code-coverage]'],
});
cy.task(
'resetCoverage',
{
// @ts-ignore
isInteractive: Cypress.config('isInteractive'),
},
{ log: false }
).then(() => {
logInstance.end();
});
});
beforeEach(() => {
// each object will have the coverage and url pathname
// to let the user know the coverage has been collected
windowCoverageObjects = [];
const saveCoverageObject = (win: any) => {
console.log('wwwww', win, win.windows?.__coverage__, win.__coverage__);
// if application code has been instrumented, the app iframe "window" has an object
const applicationSourceCoverage = win.__coverage__;
if (!applicationSourceCoverage) {
return;
}
if (
Cypress._.find(windowCoverageObjects, {
coverage: applicationSourceCoverage,
})
) {
// this application code coverage object is already known
// which can happen when combining `window:load` and `before` callbacks
return;
}
windowCoverageObjects.push({
coverage: applicationSourceCoverage,
pathname: win.location.pathname,
});
};
// save reference to coverage for each app window loaded in the test
cy.on('window:load', saveCoverageObject);
// save reference if visiting a page inside a before() hook
cy.window({ log: false }).then(saveCoverageObject);
});
afterEach(() => {
// save coverage after the test
// because now the window coverage objects have been updated
windowCoverageObjects.forEach((cover) => {
sendCoverage(cover.coverage, cover.pathname);
});
if (!hasE2ECoverage()) {
if (hasUnitTestCoverage()) {
logMessage(`👉 Only found unit test code coverage.`);
} else {
const expectBackendCoverageOnly = Cypress._.get(
Cypress.env('codeCoverage'),
'expectBackendCoverageOnly',
false
);
if (!expectBackendCoverageOnly) {
logMessage(`
Could not find any coverage information in your application
by looking at the window coverage object.
Did you forget to instrument your application?
See [code-coverage#instrument-your-application](https://github.com/cypress-io/code-coverage#instrument-your-application)
`);
}
}
}
});
after(() => {
// I wish I could fail the tests if there is no code coverage information
// but throwing an error here does not fail the test run due to
// https://github.com/cypress-io/cypress/issues/2296
// there might be server-side code coverage information
// we should grab it once after all tests finish
// @ts-ignore
const baseUrl = Cypress.config('baseUrl') || cy.state('window').origin;
// @ts-ignore
const runningEndToEndTests = baseUrl !== Cypress.config('proxyUrl');
const specType = Cypress._.get(Cypress.spec, 'specType', 'integration');
const isIntegrationSpec = specType === 'integration';
if (runningEndToEndTests && isIntegrationSpec) {
// we can only request server-side code coverage
// if we are running end-to-end tests,
// otherwise where do we send the request?
const url = Cypress._.get(Cypress.env('codeCoverage'), 'url', '/__coverage__');
cy.request({
url,
log: false,
failOnStatusCode: false,
})
.then((r) => Cypress._.get(r, 'body.coverage', null))
.then((coverage) => {
if (!coverage) {
// we did not get code coverage - this is the
// original failed request
const expectBackendCoverageOnly = Cypress._.get(
Cypress.env('codeCoverage'),
'expectBackendCoverageOnly',
false
);
if (expectBackendCoverageOnly) {
throw new Error(`Expected to collect backend code coverage from ${url}`);
} else {
// we did not really expect to collect the backend code coverage
return;
}
}
sendCoverage(coverage, 'backend');
});
}
});
after(() => {
// collect and merge frontend coverage
// if spec bundle has been instrumented (using Cypress preprocessor)
// then we will have unit test coverage
// NOTE: spec iframe is NOT reset between the tests, so we can grab
// the coverage information only once after all tests have finished
// @ts-ignore
const unitTestCoverage = window.__coverage__;
if (unitTestCoverage) {
sendCoverage(unitTestCoverage, 'unit');
}
});
after(() => {
// when all tests finish, lets generate the coverage report
const logInstance = Cypress.log({
name: 'Coverage',
message: ['Generating report [@cypress/code-coverage]'],
});
cy.task('coverageReport', null, {
timeout: dayjs.duration(3, 'minutes').asMilliseconds(),
log: false,
}).then((coverageReportFolder) => {
logInstance.set('consoleProps', () => ({
'coverage report folder': coverageReportFolder,
}));
logInstance.end();
return coverageReportFolder;
});
});
};
// to disable code coverage commands and save time
// pass environment variable coverage=false
// cypress run --env coverage=false
// or
// CYPRESS_coverage=false cypress run
// see https://on.cypress.io/environment-variables
// to avoid "coverage" env variable being case-sensitive, convert to lowercase
const cyEnvs = Cypress._.mapKeys(Cypress.env(), (value, key) => key.toLowerCase());
if (cyEnvs.coverage === false) {
console.log('Skipping code coverage hooks');
} else if (Cypress.env('codeCoverageTasksRegistered') !== true) {
// register a hook just to log a message
before(() => {
logMessage(`
Code coverage tasks were not registered by the plugins file.
See [support issue](https://github.com/cypress-io/code-coverage/issues/179)
for possible workarounds.
`);
});
} else {
registerHooks();
}

View file

@ -207,14 +207,25 @@ ${JSON.stringify(cypressConfigFile, null, 2)}
const failedSpecFilePaths: string[] = [];
const runSpecs = async (filePaths: string[]) =>
pMap(
pMap<
string,
| CypressCommandLine.CypressRunResult
| CypressCommandLine.CypressFailedRunResult
| undefined
>(
filePaths,
async (filePath) => {
let result:
| CypressCommandLine.CypressRunResult
| CypressCommandLine.CypressFailedRunResult
| undefined;
await withProcRunner(log, async (procs) => {
failedSpecFilePaths.push(filePath);
await withProcRunner<
| CypressCommandLine.CypressRunResult
| CypressCommandLine.CypressFailedRunResult
| undefined
>(log, async (procs) => {
const abortCtrl = new AbortController();
const onEarlyExit = (msg: string) => {
@ -435,12 +446,11 @@ ${JSON.stringify(cyCustomEnv, null, 2)}
env: cyCustomEnv,
},
});
if ((result as CypressCommandLine.CypressRunResult)?.totalFailed) {
failedSpecFilePaths.push(filePath);
if (!(result as CypressCommandLine.CypressRunResult)?.totalFailed) {
_.pull(failedSpecFilePaths, filePath);
}
} catch (error) {
result = error;
failedSpecFilePaths.push(filePath);
}
}
@ -465,7 +475,7 @@ ${JSON.stringify(cyCustomEnv, null, 2)}
// If there are failed tests, retry them
const retryResults = await runSpecs([...failedSpecFilePaths]);
renderSummaryTable([
const finalResults = [
// Don't include failed specs from initial run in results
..._.filter(
initialResults,
@ -477,7 +487,10 @@ ${JSON.stringify(cyCustomEnv, null, 2)}
)
),
...retryResults,
] as CypressCommandLine.CypressRunResult[]);
] as CypressCommandLine.CypressRunResult[];
renderSummaryTable(finalResults);
const hasFailedTests = (
runResults: Array<
| CypressCommandLine.CypressFailedRunResult
@ -496,6 +509,10 @@ ${JSON.stringify(cyCustomEnv, null, 2)}
const hasFailedInitialTests = hasFailedTests(initialResults);
const hasFailedRetryTests = hasFailedTests(retryResults);
if (finalResults.length !== files.length) {
throw createFailError('Cypress crashed', { exitCode: -1 });
}
// If the initialResults had failures and failedSpecFilePaths was not populated properly return errors
if (hasFailedRetryTests || (hasFailedInitialTests && !retryResults.length)) {
throw createFailError('Not all tests passed');

View file

@ -1511,21 +1511,6 @@
resolved "https://registry.yarnpkg.com/@csstools/selector-specificity/-/selector-specificity-2.0.1.tgz#b6b8d81780b9a9f6459f4bfe9226ac6aefaefe87"
integrity sha512-aG20vknL4/YjQF9BSV7ts4EWm/yrjagAN7OWBNmlbEOUiu0llj4OGrFoOKK3g2vey4/p2omKCoHrWtPxSwV3HA==
"@cypress/code-coverage@^3.12.18":
version "3.12.19"
resolved "https://registry.yarnpkg.com/@cypress/code-coverage/-/code-coverage-3.12.19.tgz#5bf197cb48826c315c7cce7acf1b3057de34a033"
integrity sha512-RNpgESArIwX2PG7k0KEb941eSYSBEGF1WB5NPeWrVJMX6KeAxj3Ki5aeYlFeV+wxoAJ+7gcF4s5xV18BQLCpjQ==
dependencies:
"@cypress/webpack-preprocessor" "^6.0.0"
chalk "4.1.2"
dayjs "1.11.10"
debug "4.3.4"
execa "4.1.0"
globby "11.1.0"
istanbul-lib-coverage "^3.0.0"
js-yaml "4.1.0"
nyc "15.1.0"
"@cypress/grep@^4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@cypress/grep/-/grep-4.0.1.tgz#bce679f85da286c4979bb9ffc79b2782dc5b75c6"
@ -1559,7 +1544,7 @@
tunnel-agent "^0.6.0"
uuid "^8.3.2"
"@cypress/webpack-preprocessor@^6.0.0", "@cypress/webpack-preprocessor@^6.0.1":
"@cypress/webpack-preprocessor@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/@cypress/webpack-preprocessor/-/webpack-preprocessor-6.0.1.tgz#5369527c063b2f4718a125ddbd163c5775086e06"
integrity sha512-WVNeFVSnFKxE3WZNRIriduTgqJRpevaiJIPlfqYTTzfXRD7X1Pv4woDE+G4caPV9bJqVKmVFiwzrXMRNeJxpxA==
@ -10283,7 +10268,7 @@
dependencies:
"@types/node" "*"
"@types/node@*", "@types/node@20.10.5", "@types/node@>= 8", "@types/node@>=12.12.47", "@types/node@>=13.7.0", "@types/node@>=18.0.0", "@types/node@^14.0.10 || ^16.0.0", "@types/node@^14.14.20 || ^16.0.0", "@types/node@^18.0.0", "@types/node@^18.11.18":
"@types/node@*", "@types/node@20.10.5", "@types/node@>= 8", "@types/node@>=12.12.47", "@types/node@>=13.7.0", "@types/node@>=18.0.0", "@types/node@^14.0.10 || ^16.0.0", "@types/node@^14.14.20 || ^16.0.0", "@types/node@^18.0.0", "@types/node@^18.11.18", "@types/node@^18.17.5":
version "20.10.5"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.5.tgz#47ad460b514096b7ed63a1dae26fad0914ed3ab2"
integrity sha512-nNPsNE65wjMxEKI93yOP+NPGGBJz/PoN3kZsVLee0XMiJolxSekEVD8wRwBUBqkwc7UWop0edW50yrCQW4CyRw==
@ -13439,14 +13424,6 @@ chalk@2.4.2, chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2:
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"
chalk@4.1.2, chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2, chalk@~4.1.0:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"
chalk@^1.0.0:
version "1.1.3"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
@ -13466,6 +13443,14 @@ chalk@^3.0.0:
ansi-styles "^4.1.0"
supports-color "^7.1.0"
chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2, chalk@~4.1.0:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"
chalk@^5.1.2, chalk@^5.2.0, chalk@^5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.3.0.tgz#67c20a7ebef70e7f3970a01f90fa210cb6860385"
@ -14706,13 +14691,14 @@ cypress-recurse@^1.35.2:
dependencies:
humanize-duration "^3.27.3"
cypress@^13.6.3:
version "13.6.3"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.6.3.tgz#54f03ca07ee56b2bc18211e7bd32abd2533982ba"
integrity sha512-d/pZvgwjAyZsoyJ3FOsJT5lDsqnxQ/clMqnNc++rkHjbkkiF2h9s0JsZSyyH4QXhVFW3zPFg82jD25roFLOdZA==
cypress@13.6.2:
version "13.6.2"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.6.2.tgz#c70df09db0a45063298b3cecba2fa21109768e08"
integrity sha512-TW3bGdPU4BrfvMQYv1z3oMqj71YI4AlgJgnrycicmPZAXtvywVFZW9DAToshO65D97rCWfG/kqMFsYB6Kp91gQ==
dependencies:
"@cypress/request" "^3.0.0"
"@cypress/xvfb" "^1.2.4"
"@types/node" "^18.17.5"
"@types/sinonjs__fake-timers" "8.1.1"
"@types/sizzle" "^2.3.2"
arch "^2.2.0"
@ -15086,7 +15072,7 @@ dateformat@^4.5.1:
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-4.6.3.tgz#556fa6497e5217fedb78821424f8a1c22fa3f4b5"
integrity sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==
dayjs@1.11.10, dayjs@^1.10.4:
dayjs@^1.10.4:
version "1.11.10"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.10.tgz#68acea85317a6e164457d6d6947564029a6a16a0"
integrity sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==
@ -18334,18 +18320,6 @@ globby@10.0.0:
merge2 "^1.2.3"
slash "^3.0.0"
globby@11.1.0, globby@^11.0.1, globby@^11.0.2, globby@^11.0.4, globby@^11.1.0:
version "11.1.0"
resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b"
integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==
dependencies:
array-union "^2.1.0"
dir-glob "^3.0.1"
fast-glob "^3.2.9"
ignore "^5.2.0"
merge2 "^1.4.1"
slash "^3.0.0"
globby@^10.0.1:
version "10.0.2"
resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.2.tgz#277593e745acaa4646c3ab411289ec47a0392543"
@ -18360,6 +18334,18 @@ globby@^10.0.1:
merge2 "^1.2.3"
slash "^3.0.0"
globby@^11.0.1, globby@^11.0.2, globby@^11.0.4, globby@^11.1.0:
version "11.1.0"
resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b"
integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==
dependencies:
array-union "^2.1.0"
dir-glob "^3.0.1"
fast-glob "^3.2.9"
ignore "^5.2.0"
merge2 "^1.4.1"
slash "^3.0.0"
globby@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c"
@ -23599,7 +23585,7 @@ nwsapi@^2.2.2:
resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.2.tgz#e5418863e7905df67d51ec95938d67bf801f0bb0"
integrity sha512-90yv+6538zuvUMnN+zCr8LuV6bPFdq50304114vJYJ8RDyK8D5O9Phpbd6SZWgI7PwzmmfN1upeOJlvybDSgCw==
nyc@15.1.0, nyc@^15.1.0:
nyc@^15.1.0:
version "15.1.0"
resolved "https://registry.yarnpkg.com/nyc/-/nyc-15.1.0.tgz#1335dae12ddc87b6e249d5a1994ca4bdaea75f02"
integrity sha512-jMW04n9SxKdKi1ZMGhvUTHBN0EICCRkHemEoE5jm6mTYcqcdas0ATzgUgejlQUHMvpnOZqGB5Xxsv9KxJW1j8A==