wheresrhys/fetch-mock-jest

Keep getting Unmatched GET to "http://example.com"

eden-lane opened this issue · 2 comments

My code is

import request from 'supertest';
import {app} from '../app';
jest.mock('node-fetch', () => require('fetch-mock-jest').sandbox());
const fetchMock = require('node-fetch');

test('demo created successfully', async () => {
  beforeEach(() => {
    fetchMock.get('*', {
      status: 200
    })

error:

Unmatched GET to https://example.com

Can you set up a repo with a reduced test case I can check out and run myself. Not enough info in the issue to debug

Hi! I managed to solve my problem somehow. The worst thing - I still don't understand what was the issue.
In my final code I see the line:

fetchMock.enableMocks();

maybe this line solved my problem. I don't see this line in readme and I don't know if it is really important. If it is - I think it would be a good idea to add this to README.md. If it's not important - I'm sorry that I couldn't be of much help.