Skip to content

Commit

Permalink
feat(allure-cypress): report skipped tests (fixes #948, via #1029)
Browse files Browse the repository at this point in the history
  • Loading branch information
epszaw authored Jul 1, 2024
1 parent 9c6ab51 commit 6ca62e6
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/allure-cypress/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ const {
EVENT_TEST_BEGIN,
EVENT_TEST_FAIL,
EVENT_TEST_PASS,
EVENT_TEST_PENDING,
EVENT_SUITE_BEGIN,
EVENT_SUITE_END,
EVENT_HOOK_BEGIN,
Expand Down Expand Up @@ -405,6 +406,28 @@ const initializeAllure = () => {
},
});
})
.on(EVENT_TEST_PENDING, (test: CypressTest) => {
const testRuntime = new AllureCypressTestRuntime();

testRuntime.sendMessageAsync({
type: "cypress_test_start",
data: {
id: test.id,
specPath: getSuitePath(test).concat(test.title),
filename: Cypress.spec.relative,
start: Date.now(),
},
});

return testRuntime.sendMessageAsync({
type: "cypress_test_end",
data: {
id: test.id,
status: Status.SKIPPED,
stop: Date.now(),
},
});
})
.on(EVENT_RUN_END, () => {
// this is the only way to say reporter process messages in interactive mode without data duplication
if (Cypress.config("isInteractive")) {
Expand Down
36 changes: 36 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,39 @@ 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({
"cypress/e2e/sample.cy.js": () => `
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).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,
}),
]),
);
});

0 comments on commit 6ca62e6

Please sign in to comment.