Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Error: TypeError: Cannot read property 'prototype' of undefined when using on nodejs #407
I'm almost sure it's my mistake, but I spent one entire day trying to solve and I've being failed
I'm trying to configure the fetch-mock on node to use with jest. I tried a lot of things and the best result that I have is this:
I'm sure my mock is working because if I pass it through parameter to the "Myclass.query" it works perfectly.
I'm also sure that the mock is arriving in my test file, because the mock function is present in the fetch module.
But... all together aren't working
I create a very simple and small project to see this problem happening:
Can anyone help me?
Ooooh, this is an interesting case.
I think that because you are setting a global mock for
I advise raising an issue with jest (or maybe there's a jest community site?). Please can you also reply here to let me know of any solution(s) you're given. I will definitely need to update the docs here to expand on the advice I currently give for use with jest
Hi! @wheresrhys! If I declare the mock in each test suite, I have a different problem!
If I do this locally, the fetch in my implementation is not mocked. In other words, I think the line
Actually, this was my first try
I created here another branch with the implementation as you recommended:
Could you try to help me again? Unfortunately I'm not able to find a solution for my problem.
Sorry for the slow response.
The way I suggested in the docs works if you're transpiling your server side code using babel, because
Hi @wheresrhys !
Someone answered to me at StackOverflow.
I think the solution is not good enough, because it will force me to bypass the node injection system.
But he explains the reason of the problem.