-
Notifications
You must be signed in to change notification settings - Fork 96
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
Add wait-url-change macro to make tests more reliable #675
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering why you bothered with a macro, but I think I see your motivation.
An alternative would be to have a
wait-
fn like those in Etaoin's public api.And you'd just wait for your expected URL (no need to check if it changed) and fail via timeout exception.
But then you'd not have an assertion in your test, which might feel less natural for a test.
That's probably what I would have done, but if you are still happy with your macro after reading my comment, I'm okay with it, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, a few things:
testing
block that performed a test left the browser URL state such that it was unchanged (e.g., two tests tests for the same browser URL back to back; the first passes and the second does't do anything because if the test suite is faster than the browser, it just tests the results of the previous test, not the current test). If you force a change in the URL, then it will catch mistakes like this in the test suite. That said, you could certainly remove the test for change and just look for the URL you're looking for. One issue that still has is that failure is slow. That is, if you don't get the result you're looking for, you'll have to fully timeout because you don't really know if you should continue waiting for more or not. I'd rather have all tests be fast if possible, whether passing or failing. So, that led to the "if the URL changed and it has at least enough of what I'm looking for to know that it's not Firefox'sabout:blank
nonsense, then that's good enough to say that we're ready to start making test assertions" strategy.clojure.test
assertion in it because I just wanted it to wait and detect a change, without making it too complicated beyond that. Once that change is detected, there may be multiple assertions that the test writer wants to run. There aren't examples of that in the test code right now, but I like composable pieces if possible.So, poh-tay-toe / poh-tah-toe. That said, as written the test suite passed 100%, which was interesting to see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checking if my poh-tay-toe might pique your interest at all.
Your poh-tah-toe is fine with me.