ITADN

Auto importing Vue Testing Library in test files does not work if project is using TypeScript

#319Closedmorcth 创建于 2024-08-12
bug
M
morcthcommented
<!-- Thanks for your interest in the project. We appreciate bugs filed and PRs submitted! --> <!-- - For questions related to using the library, please join the Discord server (https://discord.gg/testing-library) instead of filing an issue on GitHub. - Please fill out this template with all the relevant information so we can understand what's going on and fix the issue. - If you're issue is regarding one of the query APIs (`getByText`, `getByLabelText`, etc), then please file it on the `@testing-library/dom` repository instead. Thanks :) ---> **Describe the bug** A clear and concise description of what the bug is. I was watching a video of someone using Vue Testing Library amd writing their first test in VS Code. He typed "render" and the intellisense popped up and the TL render was the first on the list... which he chose and the import statement was added automatically to the top of the file. This was not happening for me. My project has Typescript installed and configured. I created a new vue project without Typescript and all else the same and it worked as it did in the video... the Render from TL showed up and I chose it and the import line showed up. It seems that TS can't find the functions from TL until it has already been imported while without TS it only needs to be installed and not imported for intellisense to find. **To Reproduce** Steps to reproduce the behavior: npm create vue@latest Yes to only testing with Vitest npm i -D @testing-library/vue Go to the already created HelloWorld.spec.js New blank first line in test already there Start typing "render" (no quotes of course) Correct library comes up and can be chosen and import statement generates Do the same thing except on the new project, Yes to Typescript and Vitest start typing render and test-utils render comes up as a choice but not testing-library **Expected behavior** I expect testing-library/vue's render to be a choice and auto import when using typescript like it works without ts. **Screenshots** ![Screenshot from 2024-08-12 11-56-22](https://github.com/user-attachments/assets/b98d2225-f056-4032-a921-4b3a9a2fc417) **Related information:** - `@testing-library/vue` version: 8.1.0 - `Vue` version: 3.4.29 - `node` version: 20.15.0 - `npm` (or `yarn`) version: 10.8.2 Relevant code or config (if any) ```javascript ``` **Additional context**
关闭于 2024-08-14 1 条评论