chore(expect): explicit errorMessage#37253
Merged
dgozman merged 1 commit intomicrosoft:mainfrom Sep 4, 2025
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
88c3179 to
507621c
Compare
This comment has been minimized.
This comment has been minimized.
507621c to
22575f2
Compare
This comment has been minimized.
This comment has been minimized.
pavelfeldman
approved these changes
Sep 2, 2025
This turns an error in the protocol in a successfull call with error
message in the new `errorMessage` field. Existing "element(s) not found"
error is migrated to this as well.
Note that expect protocol call may still throw for multiple reasons:
- server connection dropped
- failed to serialize expected/received value, e.g. in `toHaveJSProperty()`
- unexpected playwright bug
---
Strict mode violation
```
Error: expect(locator).toHaveText(expected) failed
Locator: locator('div')
Expected string: "foo"
Error: strict mode violation: locator('div') resolved to 2 elements:
1) <div>a</div> aka getByText('a')
2) <div>b</div> aka getByText('b')
Call log:
- Expect "toHaveText" with timeout 5000ms
- waiting for locator('div')
```
---
Invalid selector
```
Error: expect(locator).toBeVisible() failed
Locator: ##
Expected: visible
Error: Unexpected token "#" while parsing css selector "##". Did you mean to CSS.escape it?
Call log:
- Expect "toBeVisible" with timeout 5000ms
- waiting for ##
```
---
New look for "element(s) not found" error
```
Error: expect(locator).toBeVisible() failed
Locator: locator('span')
Expected: visible
Error: element(s) not found
Timeout: 5000ms
Call log:
- Expect "toBeVisible" with timeout 5000ms
- waiting for locator('span')
```
22575f2 to
3861247
Compare
Contributor
Test results for "tests 1"1 failed 2 flaky46752 passed, 819 skipped Merge workflow run. |
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.
This turns an error in the protocol into a successful call with the error message in the new
errorMessagefield. Existing "element(s) not found" error is migrated to this as well.Note that expect protocol call may still throw for multiple reasons:
toHaveJSProperty()Strict mode violation
Invalid selector
New look for "element(s) not found" error