From 113b6301f8888460c4f5e98e45686ac219ba13e9 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Tue, 11 Jul 2023 16:10:13 +0100 Subject: [PATCH] Use cypress-terminal-report (#11226) * Use cypress-terminal-report This cypress plugin gives nice console logs about what is happening: I hope it will help us debug mysteriously failing tests. In its default config, it only logs for failing tests. * another anti-morgan hack * Disable collection of `console.debug` * `ctr:info` is not real --- .github/workflows/cypress.yaml | 2 +- cypress.config.ts | 4 ++++ cypress/plugins/index.ts | 4 ++++ cypress/support/e2e.ts | 18 ++++++++++++++++++ package.json | 1 + yarn.lock | 30 ++++++++++++++++++++++++++++++ 6 files changed, 58 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 546c39ae75..23d020acc5 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -174,7 +174,7 @@ jobs: record: true parallel: true command-prefix: "yarn percy exec --parallel --" - config: '{"reporter":"cypress-multi-reporters", "reporterOptions": { "configFile": "cypress-ci-reporter-config.json" } }' + config: '{"reporter":"cypress-multi-reporters", "reporterOptions": { "configFile": "cypress-ci-reporter-config.json" }, "morgan": false }' ci-build-id: ${{ needs.prepare.outputs.uuid }} env: # pass the Dashboard record key as an environment variable diff --git a/cypress.config.ts b/cypress.config.ts index b57fe7f6c4..c3403838e6 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -38,4 +38,8 @@ export default defineConfig({ runMode: 4, openMode: 0, }, + + // disable logging of HTTP requests made to the Cypress server. They are noisy and not very helpful. + // @ts-ignore https://github.com/cypress-io/cypress/issues/26284 + morgan: false, }); diff --git a/cypress/plugins/index.ts b/cypress/plugins/index.ts index 1971a70c5b..8ef9aac788 100644 --- a/cypress/plugins/index.ts +++ b/cypress/plugins/index.ts @@ -15,6 +15,7 @@ limitations under the License. */ /// +import installLogsPrinter from "cypress-terminal-report/src/installLogsPrinter"; import PluginEvents = Cypress.PluginEvents; import PluginConfigOptions = Cypress.PluginConfigOptions; @@ -35,4 +36,7 @@ export default function (on: PluginEvents, config: PluginConfigOptions) { slidingSyncProxyDocker(on, config); webserver(on, config); log(on, config); + installLogsPrinter(on, { + // printLogsToConsole: "always", + }); } diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index 4f268966a3..2ff0197ba6 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -19,6 +19,7 @@ limitations under the License. import "@percy/cypress"; import "cypress-real-events"; import "@testing-library/cypress/add-commands"; +import installLogsCollector from "cypress-terminal-report/src/installLogsCollector"; import "./config.json"; import "./homeserver"; @@ -39,3 +40,20 @@ import "./network"; import "./composer"; import "./proxy"; import "./axe"; + +installLogsCollector({ + // specify the types of logs to collect (and report to the node console at the end of the test) + collectTypes: [ + "cons:log", + "cons:info", + "cons:warn", + "cons:error", + // "cons:debug", + "cy:log", + "cy:xhr", + "cy:fetch", + "cy:request", + "cy:intercept", + "cy:command", + ], +}); diff --git a/package.json b/package.json index 7b9ab1239a..654d793054 100644 --- a/package.json +++ b/package.json @@ -184,6 +184,7 @@ "cypress-each": "^1.13.3", "cypress-multi-reporters": "^1.6.1", "cypress-real-events": "^1.7.1", + "cypress-terminal-report": "^5.3.2", "eslint": "8.43.0", "eslint-config-google": "^0.14.0", "eslint-config-prettier": "^8.5.0", diff --git a/yarn.lock b/yarn.lock index 503cf406b4..ed65156719 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3618,6 +3618,17 @@ cypress-real-events@^1.7.1: resolved "https://registry.yarnpkg.com/cypress-real-events/-/cypress-real-events-1.8.1.tgz#d00c7fe93124bbe7c0f27296684838614d24a840" integrity sha512-8fFnA8EzS3EVbAmpSEUf3A8yZCmfU3IPOSGUDVFCdE1ke1gYL1A+gvXXV6HKUbTPRuvKKt2vpaMbUwYLpDRswQ== +cypress-terminal-report@^5.3.2: + version "5.3.2" + resolved "https://registry.yarnpkg.com/cypress-terminal-report/-/cypress-terminal-report-5.3.2.tgz#3a6b1cbda6101498243d17c5a2a646cb69af0336" + integrity sha512-0Gf/pXjrYpTkf2aR3LAFGoxEM0KulWsMKCu+52YJB6l7GEP2RLAOAr32tcZHZiL2EWnS0vE4ollomMzGvCci0w== + dependencies: + chalk "^4.0.0" + fs-extra "^10.1.0" + safe-json-stringify "^1.2.0" + semver "^7.3.5" + tv4 "^1.3.0" + cypress@^12.0.0: version "12.16.0" resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.16.0.tgz#d0dcd0725a96497f4c60cf54742242259847924c" @@ -4781,6 +4792,15 @@ form-data@~2.3.2: combined-stream "^1.0.6" mime-types "^2.1.12" +fs-extra@^10.1.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf" + integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + fs-extra@^11.0.0: version "11.1.1" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.1.1.tgz#da69f7c39f3b002378b0954bb6ae7efdc0876e2d" @@ -7829,6 +7849,11 @@ safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== +safe-json-stringify@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/safe-json-stringify/-/safe-json-stringify-1.2.0.tgz#356e44bc98f1f93ce45df14bcd7c01cda86e0afd" + integrity sha512-gH8eh2nZudPQO6TytOvbxnuhYBOvDBBLW52tz5q6X58lJcd/tkmqFR+5Z9adS8aJtURSXWThWy/xJtJwixErvg== + safe-regex-test@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/safe-regex-test/-/safe-regex-test-1.0.0.tgz#793b874d524eb3640d1873aad03596db2d4f2295" @@ -8581,6 +8606,11 @@ tunnel@^0.0.6: resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c" integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg== +tv4@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/tv4/-/tv4-1.3.0.tgz#d020c846fadd50c855abb25ebaecc68fc10f7963" + integrity sha512-afizzfpJgvPr+eDkREK4MxJ/+r8nEEHcmitwgnPUqpaP+FpwQyadnxNoSACbgc/b1LsZYtODGoPiFxQrgJgjvw== + tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"