-
-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mocha hooks do not work as expected in 1.14.0 #214
Comments
Shoot. Alright, thanks, I will take a look and either revert or fix. @visusnet would you like to take a look as well, maybe? |
hmm, does it work properly in v1.14.0 ? Or did you went straight for 1.14.1 ? |
@lgandecki I cannot run it right now because of |
It turns out that problems with hooks are caused by [this issue](badeball/cypress-cucumber-preprocessor#214)
I verified 1.14.0 and it's the same problem. |
Sorry, I mistyped |
Actually, I think this never worked properly and is a reflection of bug in cypress. :( If you run the tests separately, or through npx cypress run everything should be fine. Could you please verify that on your side in ui-testing-template-cypress ? |
Okay, I will look into running tests through |
Sure, thanks for the explanation, I just haven't used npx. |
Seems that the cucumber 'Before' hook is clobbering the mocha 'before'. I guess this is a result of https://github.com/TheBrainFamily/cypress-cucumber-preprocessor/blob/c321a171512c31700a9e856e21507955053a6cbe/lib/loader.js#L17 I tried exporting the Before hook capitalised instead of lowercased here https://github.com/TheBrainFamily/cypress-cucumber-preprocessor/blob/c321a171512c31700a9e856e21507955053a6cbe/lib/resolveStepDefinition.js#L203 and then removing the clobbering of the mocha hook in the loader line highlighted above. This results in a more expected behaviour as cypress then still recognises the mocha before hook as something that it needs to run before the actual test starts. Interestingly, however, pre 1.14.0 with |
😄 I would go with explicit require - take them off the window. const { Before: cukeBefore, After: cukeAfter} = require('cypress-cucumber-preprocesser/steps'); |
alright, let's do that! Would you want to add a few words to the README.md as well to document all this? |
Cypress events also not working with version 1.14.0 and later. https://docs.cypress.io/api/events/catalog-of-events.html#Cypress-Events Cypress.on('test:after:run', () => { And also I have noticed in 1.14.0 and above versions, cucumber JSON generation is happening after "After Hook" execution. In version 1.13.0 & 1.13.1 JSON file is getting generated as soon as feature scenario execution is completed. |
@sagorla I think we should run the cucumber JSON generation after the cucumber After hooks - this is what cucumber-js does. We should actually include the run Before and After hooks into the generated JSON file - this, however, has not been done yet. I added some logging and see "test:before:run" and "test:after:run" getting called around each test. Can you maybe put together a small repo on github illustrating the problems you are seeing and I'll take a look |
@sagorla could you please create a separate issue, as I think this one is fixed? |
After the release of 1.14.0 version global before and beforeEach hooks do not work as expected.
Global before hook is being run inside each test and beforeEach hook is being run before each test as much times as there are feature files in project.
To reproduce this issue I've created a small project.
Steps to reproduce
Tests won't have any before hook and there will be 2 beforeEach hooks in output
The text was updated successfully, but these errors were encountered: