-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Please do not recommend browser-env for browser testing #1092
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
Comments
// @lukechilds |
Regarding the two main points in that link, the docs do recommend only requiring the properties needed to prevent unnecessary globals and I don't think attaching them to That said, I'm aware this isn't the cleanest solution in the world. To match the example I think we would have create a new I feel like the current solution gets you 99% of the way there in one function call and makes sense until AVA is running natively in the browser. |
Yes. That is exactly the point! You need to test the same scenario as you will be deploying to your users. |
I understand your point. I'm not quite sure how you would get the react example working in the current recipe. It loads extra modules for testing which would also need to be built for browsers. I don't disagree with what you're saying, I still think this method is ok to easily test simple modules, but maybe it would be better to not recommend |
To defend browser-env. I feel it does exactly what it should/could do. I'm using it for testing a browser web extension, which is inherently even more difficult to test. I already have browser automation tests to guarantee if X is done Y happens. However, I can see the need for it to go away once AVA supports running in a real browser. |
I understand that some people want to abuse jsdom in ways it's not meant to be used and that are not supported. I especially understand if the author of a module geared around doing so wants to do that. But I don't think a widely-used test-runner such as ava should be recommending such practices. |
I can see your concern. Maybe we should add a disclaimer in the browser recipe that makes it clear that this is not recommended and is a temporary workaround until AVA is supported in the browser. I've just added a disclaimer to the |
Assuming your browser code runs under Node.js without compilation then IMHO Ideally though you'd compile your browser code first and test that in a less "hybrid franken-environment". I'd like to see the recipe address this distinction. I'm curious how people exercise their browser code though, there may be quite a habit of running it directly in Node.js rather than properly isolated in |
Addressed with #1355. |
That package uses an explicitly unsupported jsdom anti-pattern and is very bad practice to recommend to consumers of ava.
The text was updated successfully, but these errors were encountered: