From cbf266c05eb1e5e88d5432ebc131b3743174aaed Mon Sep 17 00:00:00 2001 From: Chris Breiding Date: Wed, 30 Aug 2023 15:30:23 -0400 Subject: [PATCH] fix: Include run.stats.skipped in results (#27695) Co-authored-by: Matt Schile --- cli/CHANGELOG.md | 6 +- cli/types/cypress-npm-api.d.ts | 1 + .../driver/cypress/e2e/e2e/dom_hitbox.cy.js | 4 +- packages/server/lib/modes/results.ts | 1 + system-tests/__snapshots__/results_spec.ts.js | 109 +++++++++++++++--- .../projects/results/cypress/e2e/spec-2.cy.js | 9 ++ system-tests/test/results_spec.ts | 2 +- 7 files changed, 112 insertions(+), 20 deletions(-) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index a583918ebd33..cd438f94ac65 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -5,7 +5,11 @@ _Released 09/12/2023 (PENDING)_ **Features:** - - Introduce a status icon representing the `latest` test run in the Sidebar for the Runs Page. Addresses [#27206](https://github.com/cypress-io/cypress/issues/27206). + - Introduces a status icon representing the `latest` test run in the Sidebar for the Runs Page. Addresses [#27206](https://github.com/cypress-io/cypress/issues/27206). + +**Bugfixes:** + +- Fixed a regression introduced in Cypress [13.0.0](#13-0-0) where the [Module API](https://docs.cypress.io/guides/guides/module-api), [`after:run`](https://docs.cypress.io/api/plugins/after-run-api), and [`after:spec`](https://docs.cypress.io/api/plugins/after-spec-api) results did not include the `stats.skipped` field for each run result. Fixes [#27694](https://github.com/cypress-io/cypress/issues/27694). Addressed in [#27695](https://github.com/cypress-io/cypress/pull/27695). ## 13.0.0 diff --git a/cli/types/cypress-npm-api.d.ts b/cli/types/cypress-npm-api.d.ts index 05811d4998cf..ffeda31685ea 100644 --- a/cli/types/cypress-npm-api.d.ts +++ b/cli/types/cypress-npm-api.d.ts @@ -246,6 +246,7 @@ declare namespace CypressCommandLine { failures: number passes: number pending: number + skipped: number startedAt: dateTimeISO suites: number tests: number diff --git a/packages/driver/cypress/e2e/e2e/dom_hitbox.cy.js b/packages/driver/cypress/e2e/e2e/dom_hitbox.cy.js index 4abec6436581..6f226aacc1c7 100644 --- a/packages/driver/cypress/e2e/e2e/dom_hitbox.cy.js +++ b/packages/driver/cypress/e2e/e2e/dom_hitbox.cy.js @@ -84,7 +84,7 @@ describe('rect highlight', { browser: '!webkit' }, () => { }) const ensureCorrectTargetPosition = (sel) => { - return cy.wrap(null, { timeout: 400 }).should(() => { + return cy.wrap(null, { timeout: 4000 }).should(() => { const target = cy.$$('div[data-highlight-hitbox]')[0].getBoundingClientRect() const dims = { @@ -101,7 +101,7 @@ const ensureCorrectTargetPosition = (sel) => { } const ensureCorrectHighlightPositions = (sel) => { - return cy.wrap(null, { timeout: 400 }).should(() => { + return cy.wrap(null, { timeout: 4000 }).should(() => { const els = { content: cy.$$('div[data-layer=Content]'), padding: cy.$$('div[data-layer=Padding]'), diff --git a/packages/server/lib/modes/results.ts b/packages/server/lib/modes/results.ts index 0ceb6150832b..9da4b263aa83 100644 --- a/packages/server/lib/modes/results.ts +++ b/packages/server/lib/modes/results.ts @@ -134,6 +134,7 @@ const createPublicRun = (run: RunResult): CypressCommandLine.RunResult => ({ failures: run.stats.failures, passes: run.stats.passes, pending: run.stats.pending, + skipped: run.stats.skipped, startedAt: run.stats.wallClockStartedAt, suites: run.stats.suites, tests: run.stats.tests, diff --git a/system-tests/__snapshots__/results_spec.ts.js b/system-tests/__snapshots__/results_spec.ts.js index 54d56f58bc5d..3021b40aa5b5 100644 --- a/system-tests/__snapshots__/results_spec.ts.js +++ b/system-tests/__snapshots__/results_spec.ts.js @@ -153,6 +153,7 @@ exports['module api and after:run results'] = ` "failures": 1, "passes": 2, "pending": 0, + "skipped": 0, "startedAt": "2015-03-18T00:00:00.000Z", "suites": 1, "tests": 3 @@ -210,11 +211,11 @@ exports['module api and after:run results'] = ` "error": null, "reporter": "spec", "reporterStats": { - "suites": 1, - "tests": 2, + "suites": 2, + "tests": 4, "passes": 1, "pending": 0, - "failures": 1, + "failures": 2, "start": "2015-03-18T00:00:00.000Z", "end": "2015-03-18T00:00:00.000Z", "duration": 100 @@ -254,6 +255,13 @@ exports['module api and after:run results'] = ` "path": "/path/to/path", "takenAt": "2015-03-18T00:00:00.000Z", "width": 1000 + }, + { + "height": 720, + "name": null, + "path": "/path/to/path", + "takenAt": "2015-03-18T00:00:00.000Z", + "width": 1280 } ], "spec": { @@ -266,12 +274,13 @@ exports['module api and after:run results'] = ` "stats": { "duration": 100, "endedAt": "2015-03-18T00:00:00.000Z", - "failures": 1, + "failures": 2, "passes": 1, "pending": 0, + "skipped": 1, "startedAt": "2015-03-18T00:00:00.000Z", - "suites": 1, - "tests": 2 + "suites": 2, + "tests": 4 }, "tests": [ { @@ -304,6 +313,36 @@ exports['module api and after:run results'] = ` "results spec 1", "test 2" ] + }, + { + "attempts": [ + { + "state": "failed" + } + ], + "displayError": ""Error: failure in beforeEach\\n\\nBecause this error occurred during a \`before each\` hook we are skipping the remaining tests in the current suite: \`has skipped tests\`\\n " + "duration": 100, + "state": "failed", + "title": [ + "results spec 1", + "has skipped tests", + "will be skipped #1" + ] + }, + { + "attempts": [ + { + "state": "skipped" + } + ], + "displayError": null, + "duration": 100, + "state": "skipped", + "title": [ + "results spec 1", + "has skipped tests", + "will be skipped #2" + ] } ], "video": null @@ -311,12 +350,12 @@ exports['module api and after:run results'] = ` ], "startedTestsAt": "2015-03-18T00:00:00.000Z", "totalDuration": 100, - "totalFailed": 2, + "totalFailed": 3, "totalPassed": 3, "totalPending": 0, - "totalSkipped": 0, - "totalSuites": 2, - "totalTests": 5 + "totalSkipped": 1, + "totalSuites": 3, + "totalTests": 7 } ` @@ -333,11 +372,11 @@ exports['after:spec results'] = ` "error": null, "reporter": "spec", "reporterStats": { - "suites": 1, - "tests": 2, + "suites": 2, + "tests": 4, "passes": 1, "pending": 0, - "failures": 1, + "failures": 2, "start": "2015-03-18T00:00:00.000Z", "end": "2015-03-18T00:00:00.000Z", "duration": 100 @@ -377,6 +416,13 @@ exports['after:spec results'] = ` "path": "/path/to/path", "takenAt": "2015-03-18T00:00:00.000Z", "width": 1000 + }, + { + "height": 720, + "name": null, + "path": "/path/to/path", + "takenAt": "2015-03-18T00:00:00.000Z", + "width": 1280 } ], "spec": { @@ -389,12 +435,13 @@ exports['after:spec results'] = ` "stats": { "duration": 100, "endedAt": "2015-03-18T00:00:00.000Z", - "failures": 1, + "failures": 2, "passes": 1, "pending": 0, + "skipped": 1, "startedAt": "2015-03-18T00:00:00.000Z", - "suites": 1, - "tests": 2 + "suites": 2, + "tests": 4 }, "tests": [ { @@ -427,6 +474,36 @@ exports['after:spec results'] = ` "results spec 1", "test 2" ] + }, + { + "attempts": [ + { + "state": "failed" + } + ], + "displayError": ""Error: failure in beforeEach\\n\\nBecause this error occurred during a \`before each\` hook we are skipping the remaining tests in the current suite: \`has skipped tests\`\\n " + "duration": 100, + "state": "failed", + "title": [ + "results spec 1", + "has skipped tests", + "will be skipped #1" + ] + }, + { + "attempts": [ + { + "state": "skipped" + } + ], + "displayError": null, + "duration": 100, + "state": "skipped", + "title": [ + "results spec 1", + "has skipped tests", + "will be skipped #2" + ] } ], "video": null diff --git a/system-tests/projects/results/cypress/e2e/spec-2.cy.js b/system-tests/projects/results/cypress/e2e/spec-2.cy.js index c286b289c012..b4411a2fa751 100644 --- a/system-tests/projects/results/cypress/e2e/spec-2.cy.js +++ b/system-tests/projects/results/cypress/e2e/spec-2.cy.js @@ -17,4 +17,13 @@ describe('results spec 1', () => { cy.log('test 2') cy.screenshot('test 2 screenshot') }) + + describe('has skipped tests', { retries: 0 }, () => { + beforeEach(() => { + throw new Error('failure in beforeEach') + }) + + it('will be skipped #1', () => {}) + it('will be skipped #2', () => {}) + }) }) diff --git a/system-tests/test/results_spec.ts b/system-tests/test/results_spec.ts index 5a4b7dd4bec2..40a224e8b08e 100644 --- a/system-tests/test/results_spec.ts +++ b/system-tests/test/results_spec.ts @@ -46,7 +46,7 @@ describe('module api, after:spec, and after:run results', () => { project: 'results', browser: 'electron', outputPath, - expectedExitCode: 2, + expectedExitCode: 3, config: { retries: 2, },