-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Importing types doesn't work in jest environment #8301
Comments
This is something that needs to be fixed in https://github.com/vuejs/vue-jest I believe. /cc @lmiller1990 It seems TypeScript does not populate |
I recently ran into the same issue, although I'm not using |
I have the same problem with version 3.2.2 and without jest. |
I think this feature is available only from |
My mistake, i'm using version 3.3.1 |
Hi there! Had anyone of you time to investigate? 🙂 Using the new cool vue 3.3 interface features (that is importing interfaces from elsewhere) our jest suite is now broken too 🥲 Would really like to step forward with vue 3.3 🥳. |
@jenshoffmann1331 Did you try the hacky solution? You basically point to a different transformer than vue-jest (https://github.com/vojvodics/vue3.3.1-jest-reproduction-example/blob/main/jest.config.js#L6) and in that file you call registerTs before exporting vue-jest (https://github.com/vojvodics/vue3.3.1-jest-reproduction-example/blob/main/vue3JestHack.js) |
@vojvodics: Yeah! I tried your hack while you were writing your comment. Works well, thank you! |
I don't think we've tried vue-jest with Vue 3.3 yet. We should add some tests in that code base and see if there's any bugs or issues. It sounds like this isn't an issue in Vue core, though - perhaps we should move the issue to vue-jest? |
Looks like d2c3d8b broke the hack suggested here. To fix it, instead of passing in
|
It looks like require("@vue/compiler-sfc").registerTS(() => require("typescript")); |
Hmm... Adding the following to
This is without the hacky code above... I wonder if there's a way to provide typescript as a peer dep in the same way? |
Vue version
3.3.2
Link to minimal reproduction
https://github.com/vojvodics/vue3.3.1-jest-reproduction-example
Steps to reproduce
Clone reproduction repository and run
npm run test
What is expected?
Tests should pass
What is actually happening?
Tests are failing with the following error:
System Info
No response
Any additional comments?
A hacky solution is provided in the repo example. It is based on these files:
https://github.com/vuejs/core/blob/v3.3.2/packages/vue/compiler-sfc/index.js
https://github.com/vuejs/core/blob/v3.3.2/packages/vue/compiler-sfc/register-ts.js
Also related:
*initially it was v3.3.1, but I updated it to v3.3.2 and it is still present
The text was updated successfully, but these errors were encountered: