From 064f0bedd0eac529c4b0d8df8fdf44e672d6212c Mon Sep 17 00:00:00 2001 From: Robert Battaglia Date: Mon, 20 May 2024 09:40:59 -0400 Subject: [PATCH] feat: cypress report skipped tests - fix lint / prettier fixes allure-framework/allure-js#948 --- packages/allure-cypress/src/index.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/packages/allure-cypress/src/index.ts b/packages/allure-cypress/src/index.ts index a37e32525..3999e3eb0 100644 --- a/packages/allure-cypress/src/index.ts +++ b/packages/allure-cypress/src/index.ts @@ -23,6 +23,7 @@ import { toReversed, uint8ArrayToBase64, } from "./utils.js"; +import {CypressTestStartRuntimeMessage} from "../dist/model"; export class AllureCypressTestRuntime implements TestRuntime { labels(...labels: Label[]) { @@ -204,6 +205,7 @@ const { EVENT_TEST_BEGIN, EVENT_TEST_FAIL, EVENT_TEST_PASS, + EVENT_TEST_PENDING, EVENT_SUITE_BEGIN, EVENT_SUITE_END, EVENT_HOOK_BEGIN, @@ -405,6 +407,32 @@ const initializeAllure = () => { }, }); }) + .on(EVENT_TEST_PENDING, (test: CypressTest) => { + const testRuntime = new AllureCypressTestRuntime(); + + const startMessage: CypressTestStartRuntimeMessage = { + type: "cypress_test_start", + data: { + id: test.id, + specPath: getSuitePath(test).concat(test.title), + filename: Cypress.spec.relative, + start: Date.now(), + }, + }; + const endMessage: CypressTestEndMessage = { + type: "cypress_test_end", + data: { + id: test.id, + status: Status.SKIPPED, + stop: Date.now(), + }, + }; + + const skippedTestMessages: CypressRuntimeMessage[] = [startMessage, endMessage]; + testRuntime.sendSkippedTestMessages(skippedTestMessages); + + setGlobalTestRuntime(testRuntime); + }) .on(EVENT_RUN_END, () => { // this is the only way to say reporter process messages in interactive mode without data duplication if (Cypress.config("isInteractive")) {