fix: fail when acting on the browser after an expected exception - #207
Open
Amoifr wants to merge 1 commit into
Open
fix: fail when acting on the browser after an expected exception#207Amoifr wants to merge 1 commit into
Amoifr wants to merge 1 commit into
Conversation
After expectException() and a request that throws, the throwing request never produced a response, so the client still holds the state of an earlier request (or none at all). Actions and assertions then either leak a raw BadMethodCallException from BrowserKit or silently run against the previous page. wrapRequest() now records that the expected exception was consumed and ensureNoException() fails the next action with an explicit message until another request is made. Fixes zenstruck#202
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #202
Implements the proposal from the issue, in the shared layer so both browsers get the same behavior:
Driver::wrapRequest()records that the expected exception was consumed (the flag is cleared by the next request and byreset()).Session::ensureNoException()already runs before every action and assertion, so it now fails fast with "The last request threw the expected exception: make another request before continuing." instead of leaking BrowserKit'sBadMethodCallExceptionor silently acting on the previous page.The shared test covers the three cases from the issue: stale previous page, no previous request at all, and recovery once another request is made.
Thanks for writing the issue up with the proposal included, it basically reviewed itself. 😄