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

[Docs]: Custom matcher example doesn't work when you have a multiple element exception #34391

Open
lukpsaxo opened this issue Jan 18, 2025 · 0 comments

Comments

@lukpsaxo
Copy link
Contributor

Page(s)

https://playwright.dev/docs/next/test-assertions#add-custom-matchers-using-expectextend

Description

The example in the docs above doesn't work if for example the locator has multiple elements - the exception gets swallowed.

You can add

    } catch (e: any) {
        // if we are testing more than 1 locator we need to show that error message
        if (e.message.includes('strict mode')) {
            throw e;
        }
        matcherResult = e.matcherResult;
    }

to work around it but I am sure there are other exceptions I am missing by just testing for strict mode.

other example in the same example: #34390
original request for this documentation: #15951 (comment)
issue raised but I was told off for not following the template: #34327
issue raised but I was told off because there are multiple issues with the example and you want seperate bugs: #34350

As I said originally I think making this custom assertion work properly is complicated - I'd prefer playwright exposed a way to do it rather than have a very complicated example.

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

No branches or pull requests

1 participant