Skip to content

feat: accept many selectors in assertSeeIn() and assertNotSeeIn() - #214

Closed
Amoifr wants to merge 1 commit into
zenstruck:1.xfrom
Amoifr:feat-16-assert-see-in-selectors
Closed

Amoifr wants to merge 1 commit into
zenstruck:1.xfrom
Amoifr:feat-16-assert-see-in-selectors

Conversation

@Amoifr

@Amoifr Amoifr commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Closes #16.

assertSeeIn() and assertNotSeeIn() now also take an iterable of selectors, exactly as sketched in the issue. Every selector must contain the text for the positive assertion, and none may for the negative one.

assertNotSeeIn() was not part of the request. I did it anyway because leaving the pair asymmetric would be surprising, happy to drop it if you would rather keep the change minimal.

The README's opening example is the case from the issue, two consecutive assertSeeIn with the same expected text, so I left it alone and documented the new form in the assertion list instead. Say the word if you want the headline example switched over too.

Checking the same text in several places took one call per selector. Both
methods now also take an iterable of selectors: every one of them must
contain the text, and for the negative assertion none of them may.

assertNotSeeIn() was not in the request, but leaving the pair asymmetric
would have been surprising.
@kbond

kbond commented Oct 10, 2026

Copy link
Copy Markdown
Member

Thanks for the PR!

I've thought about this and I'm now thinking it could ambiguous what an array could mean: AND or OR?

I'd prefer to push users to custom browser methods: assertTitleIs('Post Title').

@kbond kbond closed this Oct 10, 2026
@Amoifr

Amoifr commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for taking the time to think it over, @kbond! Fair point: my own PR had to pick AND for assertSeeIn() and NONE for assertNotSeeIn(), which kind of proves there's no obvious answer. 😄 A custom browser method like assertTitleIs() says what it checks, so that's the better way. Thanks again for merging #213 and pushing it all the way to Playwright!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Allow assertSeeIn() selector to be array or string

2 participants