-
-
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
Amazing new locators in 2.1 beta don't seem to work with the interactivity API #6449
Comments
There is no button in your reproduction. The error I get is different:
Please, provide a runnable reproduction (code repo or stackblitz link) |
Hello @xeger. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with |
I am unable to create a standalone reproduction of the exact error. Here's a gist that produces another, also seemingly valid issue. While creating the reproduction I gained some insight into the original reported issue. I will troubleshoot the original issue in situ; it seems there is some crosstalk between your API and testing-library. (My goal is to eliminate use of testing-library but it would be nice to support a gradual migration.) |
Please, if you can publish it as a repository, that would be wonderful. I can't even open the link because the files are just too big. |
Whoops, sorry about that. Here's the same thing in repo form. To save you time, in case I am being a bonehead, I updated the reproduction to find a button and click it:
I expected to reproduce
Which is similar, but not identical to the original issue -- I use vitest to find a locator, verify the locator binds to an element with an If I switch to using the playwright vitest driver (see branch This second error may be more relevant to you, since I believe vitest's intention is to support a single locators, verification & interactivity API that works with all drivers (❤️). |
This doesn't do anything, |
My apologies; Playwright + locators are completely new to me, and it's clear that I should slow down and learn about locators vs. assuming they work just like I created a playwright branch where I switch to using the playwright driver of vitest, and on that branch, all tests are passing after correcting my mistake and using Interestingly, the The same test on the main branch (using webdriverio) continues to throw
Which reinforces the idea that When using the preview driver with either branch, I continue to receive the original reported error:
I also tried copying the verbatim example test from It seems to me that The vision of a single browser testing API that works with vitest both in preview + headless mode, and is similar to the API used in (playwright) E2E tests, is very compelling to me -- which is why I persist in troubleshooting. ❤️ |
Sorry, but your tests are still not correct. Please refer to the documentation for how test('using screen', async () => {
let clicked = false;
const screen = page.render(<button onClick={() => {clicked = true}}>hello, world</button>);
- expect.element(screen.getByRole('button'));
+ await expect.element(screen.getByRole('button')).toBeDefined();
await userEvent.click(screen.getByRole('button'));
- expect.poll(() => clicked).toBe(true);
+ await expect.poll(() => clicked).toBe(true);
}); I am looking into differences between providers right now. |
Thank you for looking into it. I've upgraded the reproduction repository to 2.1.0 and corrected my tests; both the corrected test and the documented example from I will continue to troubleshoot it on my own & open a new issue if I find a root cause. |
I'll reopen the issue then. Both examples worked previously |
Small correction: there is one test case succeeding now with the preview driver! If we capture the If I'm using I've amended my reproduction to have an NPM command for each driver, and shown that the I will try to reproduce this success in the project where I was encountering trouble. Your fix has definitely improved things with preview mode! (I am not opinionated about webdriverio vs. playwright for headless tests, but of course I want to help ensure vitest remains flexible as advertised.)
|
Quick update on some more troubleshooting steps that I have tried.
The switch to PNPM revealed a missing direct dependency on The playwright driver continues to work well in all cases; the preview and WDIO drivers continue to be extremely flakey. I also noticed that the playwright driver can run in headed mode and the vitest UI is available. I appreciate that browsers and frontend are hell. I may just switch my private repository to use playwright and commit to using it in the future, as it is the only stable option. Maybe vitest should do the same thing, as a project. If the dream of vendor nenutrality is impossible to achieve, that's not your fault! |
Describe the bug
Also filed as vitest/vitest-browser-react#1 but I am cross posting here for visibility purposes.
It seems that
@vitest/browser/context
isn't properly coordinating withvitest-browser-react
. The React rendering and verification work well by themselves, but when I try to fire any user events, theuserEvent
imported from@vitest/browser/context
fails with an error.Seems like the two pieces of
@vitest/browser
aren't communicating with ech other. (I know thatvitest-browser-react
is a separate package, but it integrates tightly with@vitest/browser
, and in this case, the integration seems to be not quite right.)Troubleshooting
👎 Tried swapping the order of
render
vs.setup
👎 Tried
const user = userEvent;
in case the setup is unnecessaryReproduction
This results in:
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: