-
-
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
Example missing showing basic browser testing? #362
Comments
Vitest is for unit-testing on Node and does not run on browsers. We might need to document it more clearly tho |
testing in browsers is hugely important for libraries and anyone who needs to ensure a certain level of cross-browser support -- why not support running in browsers? |
We recommend using Cypress or Web Test runner for that as a complement of Vitest |
Those are too high level/abstracted. |
there is a similar issue for jest one thing that is tricky with adding real browser env is how to isolate context for tests in there? |
You can't fully isolate context out of the box, but existing browser testing has techniques for managing and notifying when it does happen. (Deep recursive proxies on the grobals for dirty tracking could be an option, not sure how or if they did it pre-proxies, or even if they use proxies) Non-dom/window using tests could run in parallel in workers, etc |
There's also Playwright for testing in browsers. Cypress and Playwright alone cover a humongous amount of deep and complex problems in the browser land, don't see why it would be wise to bring any of that in Vitest. Component testing w/ Cypress, while being work in progress atm, works fine and compared to traditional e2e testing is not slow at all. I'm sure there can be innovation and optimizations made in this arena as well but IMHO if would be better suited as a plugin than a core feature for Vitest. |
Playwright uses some webdriver.io stuff... which isn't what I'm after. I mean, I guess I'll just use vite and an index.html file that includes some test setup stuff. |
@NullVoxPopuli I think you should reopen because this is really needed IMO. Playwright is the closest right now with their test runner and their experimental component testing. However I'm not interested in duplicating all my tests just to run them in browser. |
Yeah, I started yet-another-testing tool: https://github.com/NullVoxPopuli/ember-addon-test (tho, focused more on getting ember.js stuff running with vite in a test environment. -- but it turns out that (so far) it's totally agnostic to any frontend framework, and could work with anything right now (except that I've only set this up with qunit for the actual test framework (I don't imagine it'd be hard to support mocha or similar, but qunit is what I use)). The main thing I have to figure out so far is launching browsers automatically (and reporting test results to the cli). I started that here: NullVoxPopuli/ember-addon-test#1 but testem (which doesn't require any additional dependencies to launch browsers (such as chromedriver or geckodriver)), isn't setup to be used by other tools... so... that's dissappointing. Would be fantastic if |
Describe the bug
The docs seem to be focused on node-testing, which for a lot of people is a deal breaker (need to test browser-compatibility across multiple browsers, maybe via browserstack, etc -- so the dom-mocking libraries are simply not an option).
Reproduction
visiting https://vitest.dev/, it's not clear if browser testing is supported.
I have a hunch it is, based on how I think vitest works, but I haven't played around with it yet.
System Info
Validations
The text was updated successfully, but these errors were encountered: