import request from 'supertest' import app from '../../../app' import { mocked } from 'ts-jest/utils' import { compare } from 'bcrypt' import { AwesomeGraphQLClient } from 'awesome-graphql-client' const mockRequestFn = jest.fn().mockReturnValue({ appUsers: [ { id: 'tests' } ] }) jest.mock('awesome-graphql-client', () => ({ AwesomeGraphQLClient: jest.fn().mockImplementation(() => ({ request: mockRequestFn })) }))
I am trying to mock a method on a non default exported class from Awesome GraphQL. I also want to spy on this method, so I created a separate jest.fn()
with a return value. The problem is that request is not a function: TypeError: client.request is not a function
.
How can I mock and spy on the method of a mocked non default exported class?
https://stackoverflow.com/questions/66699145/how-to-mock-a-method-on-a-non-default-exported-class March 19, 2021 at 05:07AM
没有评论:
发表评论