Skip to content

Commit

Permalink
feat: cypress report skipped tests
Browse files Browse the repository at this point in the history
fixes #948
  • Loading branch information
RobertBattaglia authored and epszaw committed Jul 1, 2024
1 parent 064f0be commit b9deda1
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/allure-cypress/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ 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 {
Expand Down Expand Up @@ -521,6 +531,12 @@ const initializeAllure = () => {
});
});

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[];

Expand Down
26 changes: 26 additions & 0 deletions packages/allure-cypress/test/spec/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,29 @@ it("broken test", async () => {
expect(tests[0].stage).toBe(Stage.FINISHED);
expect(tests[0].statusDetails).toHaveProperty("message", "broken");
});

it("skipped tests", async () => {
const { tests } = await runCypressInlineTest(
() => `
it.skip("skipped-1", () => {
cy.wrap(1).should("eq", 1);
});
it("passing", () => {
cy.wrap(1).should("eq", 1);
});
it.skip("skipped-2", () => {
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);
});

0 comments on commit b9deda1

Please sign in to comment.