Open ktryniszewski-mdsol opened 3 years ago
You have no idea how grateful i am for your comment. Never would have guessed that codeceptjs had this strange mechanism.
You have no idea how grateful i am for your comment. Never would have guessed that codeceptjs had this strange mechanism.
Yea there seems to be an underlying issue with how backgrounds are mapped to mocha's internal beforeEach
. From current behavior it seems like they are being executed as beforeAll
where it is only supposed to run once before a series of tests.
What is also odd, none of the logic you implement in a before
hook is accessible in the background
https://codecept.io/bdd/#before
Meaning that retries wont be performed on background steps. Or if you try to setup a state object, it wont be accessible in the background steps.
Seems like a major flaw in how its currently implemented. I tried stepping through the code but didnt have enough time to investigate further
Thanks, looks like an severe bug. Not sure I will get time to check it out but any help is highly aporeciated
Getting the same behaviour with Playwright
We're running into the same issue as well, but in our case we have an error being thrown inside of a Before block. The same result happens where subsequent tests in the file are skipped.
Let me just clarify that Background is indeed executed as beforeEach:
See lib/interfaces/gherkin.js:101
What are you trying to achieve?
Run a feature file without failing fast and skipping tests if background fails.
What do you get instead?
If you have a feature file with 5 scenarios and a Background. If a background step fails on scenario 3, then scenario 4 and 5 are marked as skipped. As we know sometimes a step fails because of timing issues or a page fails to load, this doesnt mean the background will fail each time. Isn't a Background treated as a beforeEach in mocha anyway? So it should run independently for each scenario.
steps:
feature file
Details