jest mock return new

39 阅读1分钟
jest.mock(moduleName,moduleFactory)

moduleFactory must return a high class function to be able to new

this works:

jest.mock('moduleName', () => {
  return {
    Session: jest.fn().mockImplementation(() => {
      return mockSession
    }),
  }
})