Shelex / cypress-allure-plugin

cypress plugin to use allure reporter api in tests

Home Page:https://shelex.github.io/cypress-allure-plugin-example/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generate tests in forEach loop mark first loop with tests as skipped

PeaceDate opened this issue · comments

Reopened #183

Updated to latest version of Cypress allure plugin. Problem still reproduce

Steps to reproduce

  1. Clone this repo
  2. Run yarn install
  3. Run npm run cypress:test
  4. Run npm run report:generate
  5. Run npm run report:open

Result -> First test ignored and marked as skipped
Screenshot 2023-02-02 at 22 06 09

@shelex/cypress-allure-plugin: "2.35.0"
cypress: "10"

@PeaceDate Thank you for an example repo, that helped a lot.

Now I see that problem is not a forEach loop actually, but the changing domain, so this issue is identical to #179 and #125.

It is caused by a way Cypress work - baseUrl is absent, same file involving different domains (technically, localhost:3001 and localhost:3002 are different), thus Cypress reloads the page completely and erases previous allure object.

I don't see any quick solution for this, as there is no clear way how to identify that Cypress decided to clear the state, so we could keep reporter object in some safe place, and then put into the new window state.

@Shelex That make sence. I haven't figured out. Thank you a lot :)

UPD:
What happens in case of changing domains:

  • cypress clears the state
  • creates new mocha runner
  • replays events for suite - create new, start
  • starts pending event for previous tests
  • starts end event for previous tests

Without domain changing cypress fires "test pending" event only in case it is going to be skipped.
So in v2.35.1 I upgraded handler for "end test" event, and in case test was not skipped - set proper status.
However, as state was cleared, test object is empty, meaning there will be no steps attached - that is still to be investigated how to resolve.

@Shelex HI, I checked and it works as you said. Thank you a lot, I'll continue monitoring this question for new changes and no steps attached issue.

Have a good day and Take care of yourself : )

@Shelex
Isn't working with Mocha.Context.skip() when it add like Cypress custom command
Get an error TypeError: Cannot read properties of undefined (reading 'state') Because this error occurred during a after all hook we are skipping all of the remaining tests.

Cypress.Commands.add('skipWhen', function (condition) {
    if (condition) {
        this.skip()
    }
})

Added such an example in the repo called skipTestwithSkipWhen.cy.ts

@PeaceDate case with optional skip is fixed in v2.35.2

@Shelex Thank you, I've checked already. Everything is working fine 🔥