How to use the node-fetch.mockClear function in node-fetch

To help you get started, we’ve selected a few node-fetch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TheBrainFamily / TheBrain2.0 / server / src / api / resolvers-graphql.spec.js View on Github external
beforeEach(async () => {
    fetch.mockClear()
    fetch.mockImplementation(async (query) => {
      if (query.includes(`https://graph.facebook.com/me?access_token=correctAccessToken`)) {
        return {
          json: () => ({id: 'testFbUserId'})
        }
      }
      if (query.includes(`https://graph.facebook.com/app/?access_token=correctAccessToken`)) {
        return {
          json: () => ({id: 'MOCKED_FB_APP_ID'})
        }
      }
      if (query.includes(`https://graph.facebook.com/v2.10/`)) {
        return {
          json: () => ({id: 'testFbUserId', name: 'testUserName', email: 'test@thebrain.pro'})
        }
      }