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
docs: improve testing component example to avoid auto import misunderstanding #27120
Comments
Start a new pull request in StackBlitz Codeflow. |
I think the docs are misleading there. You have to explicitly import the component. "Auto imports" of sub components should work fine. PR welcome to improve it! |
Thanks @manniL - appreciate your feedback - I'll look at a PR for the docs. |
Thank you! I would suggest doing this: import { SomeComponent } from '#components' The auto-import of components that is supported in the runtime environment is within the component (e.g. SomeComponent doesn't have to explicitly import components used in it), not within the test file. |
Environment
Reproduction
https://stackblitz.com/edit/github-aygvkp?file=components%2Fcomponent.nuxt.test.ts
Open the stackblitz and notice that the editor complains:
Run the test suite and notice that the tests fail with:
Describe the bug
I have followed the instructions on https://nuxt.com/docs/getting-started/testing and the way I read this section
SomeComponent
should be auto-imported into that test.The test suite runs successfully and all tests pass if I uncomment the SomeComponent import on line 4 but according to the example in the doc, that isn't necessary. Also, when I uncomment line 4, I get the following error:
Compare this to a similar import in
SomeWrapperComponent.vue
which does not cause the error.Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: