TypeError: (0 , _jestGetType.getType) is not a function

April 18, 2023
Chetan Agrawal
The reason why we see this error is that the type of the return type of mock values is not accurate and that breaks the system.
import * as LIB from 'path/to/your/library'; jest.mock('path/to/your/library'); jest.spyOn(LIB, 'someFunction').mockReturnValue({ type: foo } as any); // here foo is not of type expected by response // even if you do as any, that returns in some error.
This still doesnt solve for 100% of the cases.
Will dive deeper and post updates to find out more.
screen.queryAllByTestId('wrong tile id '); // this was also a potential issue
There seems to be some internal type testing inside testing library which fails if the query doest work well.
Will share some code instances to help resolve.
The expectation type is incorrect