diff --git a/packages/allure-cypress/src/index.ts b/packages/allure-cypress/src/index.ts index 065655551..2d955502d 100644 --- a/packages/allure-cypress/src/index.ts +++ b/packages/allure-cypress/src/index.ts @@ -23,7 +23,6 @@ import { toReversed, uint8ArrayToBase64, } from "./utils.js"; -import {CypressTestStartRuntimeMessage} from "../dist/model"; export class AllureCypressTestRuntime implements TestRuntime { labels(...labels: Label[]) { @@ -197,16 +196,6 @@ export class AllureCypressTestRuntime implements TestRuntime { return Cypress.Promise.resolve(); } - - sendSkippedTestMessages(messages: CypressRuntimeMessage[]) { - const skippedTestsMessages: CypressRuntimeMessage[][] | undefined = Cypress.env("skippedTestsMessages"); - - if (!skippedTestsMessages) { - Cypress.env("skippedTestsMessages", [messages]); - } else { - skippedTestsMessages.push(messages); - } - } } const { @@ -420,7 +409,7 @@ const initializeAllure = () => { .on(EVENT_TEST_PENDING, (test: CypressTest) => { const testRuntime = new AllureCypressTestRuntime(); - const startMessage: CypressTestStartRuntimeMessage = { + testRuntime.sendMessageAsync({ type: "cypress_test_start", data: { id: test.id, @@ -428,20 +417,16 @@ const initializeAllure = () => { filename: Cypress.spec.relative, start: Date.now(), }, - }; - const endMessage: CypressTestEndMessage = { + }); + + return testRuntime.sendMessageAsync({ 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 @@ -531,11 +516,11 @@ const initializeAllure = () => { }); }); - afterEach(() => { - const runtimeMessages = Cypress.env("allureRuntimeMessages") as CypressMessage[]; - - cy.task("allureReportTest", runtimeMessages, { log: false }); - }); + // afterEach(() => { + // const runtimeMessages = Cypress.env("allureRuntimeMessages") as CypressMessage[]; + // + // cy.task("allureReportTest", runtimeMessages, { log: false }); + // }); after(ALLURE_REPORT_SHUTDOWN_HOOK, () => { const runtimeMessages = Cypress.env("allureRuntimeMessages") as CypressMessage[]; diff --git a/packages/allure-cypress/src/model.ts b/packages/allure-cypress/src/model.ts index 62f3ba4cb..9d7a1321f 100644 --- a/packages/allure-cypress/src/model.ts +++ b/packages/allure-cypress/src/model.ts @@ -5,6 +5,8 @@ export const ALLURE_REPORT_SHUTDOWN_HOOK = "__allure_report_shutdown_hook__"; export const ALLURE_REPORT_STEP_COMMAND = "__allure_report_step_command__"; +// export const ALLURE_REPORT_SKIPPED_TESTS_HANDLER = "__allure_report_skipped_tests_handler__"; + export type CypressTest = Mocha.Test & { wallClockStartedAt?: Date; hookName?: string; diff --git a/packages/allure-cypress/test/spec/base.test.ts b/packages/allure-cypress/test/spec/base.test.ts index 5aaaa0ad6..50f5d89dc 100644 --- a/packages/allure-cypress/test/spec/base.test.ts +++ b/packages/allure-cypress/test/spec/base.test.ts @@ -46,8 +46,8 @@ it("broken test", async () => { }); it("skipped tests", async () => { - const { tests } = await runCypressInlineTest( - () => ` + const { tests } = await runCypressInlineTest({ + "cypress/e2e/sample.cy.js": () => ` it.skip("skipped-1", () => { cy.wrap(1).should("eq", 1); }); @@ -58,15 +58,25 @@ it("skipped tests", async () => { cy.wrap(2).should("eq", 2); }); `, - ); - - expect(tests).toHaveLength(3); - // The passing test is first, because afterEach hook runs before after hook - expect(tests[0].status).toBe(Status.PASSING); - expect(tests[0].stage).toBe(Stage.FINISHED); + }); - expect(tests[1].status).toBe(Status.SKIPPED); - expect(tests[1].stage).toBe(Stage.FINISHED); - expect(tests[2].status).toBe(Status.SKIPPED); - expect(tests[2].stage).toBe(Stage.FINISHED); + expect(tests).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + name: "passing", + status: Status.PASSED, + stage: Stage.FINISHED, + }), + expect.objectContaining({ + name: "skipped-1", + status: Status.SKIPPED, + stage: Stage.FINISHED, + }), + expect.objectContaining({ + name: "skipped-2", + status: Status.SKIPPED, + stage: Stage.FINISHED, + }), + ]), + ); }); diff --git a/packages/allure-cypress/test/utils.ts b/packages/allure-cypress/test/utils.ts index 917679fb9..b5293131a 100644 --- a/packages/allure-cypress/test/utils.ts +++ b/packages/allure-cypress/test/utils.ts @@ -107,7 +107,7 @@ export const runCypressInlineTest = async (testFiles: CypressTestFiles): Promise } } - await rm(testDir, { recursive: true }); + // await rm(testDir, { recursive: true }); return resolve(res); } catch (err) {