-
Notifications
You must be signed in to change notification settings - Fork 450
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
prototype does not exist on mocked instances #1069
Comments
hi, I can't reproduce your issue on a newly generated project by using Vue CLI. I have the project setup here. Maybe there is sth wrong in your project config ? |
Hi @ahnpnl, thank you for your response. I am actually using the following versions: If I use the following versions, then the problem disappear: Could you please upgrade your versions of @types/jest, jest, and ts-jest from v23 to v24 and try again. The problem is that my IDE does not recognize the existing of prototype field inside MockedVue although it actually exists. |
hmm, I just tried upgrading dependencies like yours but still couldn't reproduce the issue (updated master branch of the sample repo too). |
ok I could reproduce the issue. Actually with CLI it doesn't work either when I wrote In my opinion, the previous return type wasn't correct and the new return type actually makes more sense. To fix your issue, I suggest:
Because $apollo actually exists on |
Hi again. I have not finished the tests yet. I am only trying to make my IDE recognizes the existing of |
@ahnpnl Now what is your suggestion to make my IDE recognizes |
I think maybe it's typing issue from PR is welcome 👍 |
I will try to look into it, but if you suspect a specific line in the typing that would help. Currently, I am using in
The moment I remove Any clue? :( |
it is caused by your Your
Regarding to typing in testing.ts, I'm not sure which line but somewhere inside there... |
Thank you so much @ahnpnl, you are such a great help to me :) I have updated the repo if you would like to take a look. BTW, do I still need the following line in my configuration since I am using I will give |
I think the executed codes are around this. I can't remember if Using |
So are you saying that if I set |
babel-jest is shipped together with jest so you don't have to explicitly install it. When you don't set babelConfig to true, ts-jest will transform js as well as ts. Set it to true, babel doesn't know it immediately but you have to add regex in transform property of jest config to say: if js files use babel, if ts file use ts-jest |
Very clear now. I quickly went over the code in 1- it seems that it intentionally merges 2-
|
I haven't used babel yet with ts-jest. But looking at Vue generated project, target is set to esnext and it has Babel config and the tests work so I think your thought is correct |
There is a discussion about this util mock in #1048. I think jest team will take care of this. Perhaps you can raise your concern about this typing there. |
Greetings @ahnpnl. I have a question for you :) Is it possible to configure Thank you in advance. |
you can check it here |
@ahnpnl, I have read the docs multiple times but it is still not clear to me. What is clear is that you can use |
As far as I remember your case is not possible, couldn't remember where the discussion was. |
Hi again. What I am asking for is simply a way to chain I would love to use |
according to this line look like babel-jest is invoked after typescript compiler. In addition to that, the doc also confirms. In general |
close in favor of #1048 |
Issue :
`
import { mocked } from 'ts-jest/utils'
import Vue from 'vue'
jest.mock('vue')
const MockedVue = mocked(Vue, true)
// MockedVue.prototype does not exist
`
Expected behavior :
MockedVue.prototype should exist
Debug log:
Error:(9, 11) TS2339: Property 'prototype' does not exist on type 'MockedObjectDeep<VueConstructor>'.
The text was updated successfully, but these errors were encountered: