-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix(browser): explain TypeScript support in docs and add asymmetric matchers to types #6934
fix(browser): explain TypeScript support in docs and add asymmetric matchers to types #6934
Conversation
@kettanaito let me know if this is clear enough - any recommendations are also welcome 😄 I removed mentions about |
✅ Deploy Preview for vitest-dev ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Thank you for improving the docs!
I left a few comments, please let me know what you think.
What's working and not working currently (and expected to work in the future)? Would this already work with await expect.element(page.getByRole('button')).toEqual(expect.toHaveTextContent('First')) |
Yes,
Example in the PR shouldn't work (I didn't run it) because there is no |
@sheremet-va, despite |
@kettanaito Can you show your code? It's not expected to work for locator directly and that's how I see locally too with the following code: import { page } from '@vitest/browser/context';
import { expect, test } from 'vitest';
test('asymmetric', async () => {
document.body.innerHTML = '<div><input value="hi" placeholder="message" /></div>'
// OK
await expect.element(page.getByPlaceholder('message')).toEqual(expect.toHaveValue('hi'))
// OK
expect(page.getByPlaceholder('message').element()).toEqual(expect.toHaveValue('hi'))
// ERROR: received value must be an HTMLElement or an SVGElement.
expect(page.getByPlaceholder('message')).toEqual(expect.toHaveValue('hi'))
}) |
Description
This PR adds more examples on how to make TS see
expect.*
types and also adds missing asymmetrict matchers type definitions:(Asymmetric definitions only support Elements, they don't support locators yet)
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yaml
unless you introduce a new test example.Tests
pnpm test:ci
.Documentation
pnpm run docs
command.Changesets
feat:
,fix:
,perf:
,docs:
, orchore:
.