Skip to content
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

Always reactivate the plugin after tests #7

Closed
wants to merge 2 commits into from

Conversation

BrianHenryIE
Copy link

Moves the activate plugin code from the end of each test case into the afterEach() method.

Otherwise, when an individual test fails, the plugin is not reactivated and subsequent tests fail where they expect it to be loaded. afterEach() always runs, like try-catch-finally.

Cypress highlights this as an anti-pattern in their best practices guide. It should be done in a before/beforeEach but that would require updating all test suites which could possibly run after this one.

@circlecube
Copy link
Member

I think we'd need to update the tests here to work a bit differently if adding an afterEach. Some of the steps don't disable the plugin so on those wouldn't this error since there isn't an activate link when it's already active.

Alternatively, we could use a CLI command to activate - probably takes a little longer to run, but should always work.

@BrianHenryIE
Copy link
Author

OK, I'll take another look. I thought since cy.get().then({}) doesn't perform an assertion, it woudn't fail when there is no activate button, and would only run the then closure when there is a deactivate button. I see the failing tests there, though.

@circlecube
Copy link
Member

Looks like it is still failing with the if seems like the find inside the if will still cause the test to fail?

@circlecube
Copy link
Member

I'll close this out since #8 should resolve the issue by reactivating the plugin after these tests via a cli command.

@circlecube circlecube closed this Feb 8, 2024
@circlecube circlecube deleted the cypress-move-reactive-plugin-to-aftereach branch February 8, 2024 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants