wheresrhys / fetch-mock-jest

Jest wrapper for fetch-mock, a comprehensive stub for fetch
http://www.wheresrhys.co.uk/fetch-mock/
MIT License
60 stars 11 forks source link

TypeError: debug is not a function #25

Open willxtong opened 3 years ago

willxtong commented 3 years ago

Trying to use the latest version of fetch-mock-jest in my project, but seeing the below error:

image

willxtong commented 3 years ago

Seeing the same issue with the latest version of fetch-mock as well:

image

wheresrhys commented 3 years ago

Weird - pin fetch-mock to 9.9.0 for now and hopefully that will work. I'll investigate the failure today

wheresrhys commented 3 years ago

try latest fetch-mock & fetch-mock-jest and reopen if still an issue

gilbarbara commented 3 years ago

hey @wheresrhys

I'm having the same error with 9.x for quite some time. I kept using 8.x but now I decided to try this package and the error continues.

wheresrhys commented 3 years ago

Can you create a repo with a reduced test case so I can investigate further please.

akarshan1996 commented 2 years ago

Hey @wheresrhys ,

I have been also getting the below error;

Screenshot 2021-09-20 at 5 26 51 PM

Code and configurations are below: Version "fetch-mock": "^9.9.0", "fetch-mock-jest": "^1.5.1", "jest": "26.6.3", "@types/jest": "26.0.23", "babel-jest": "^27.2.0", "eslint-plugin-jest": "^23.20.0", "ts-jest": "^27.0.5",

package.json "jest": { "preset": "ts-jest", "transform": { "^.+\.(ts|tsx)?$": "ts-jest", "^.+\.(js|jsx)$": "babel-jest" }, "testRegex": "./test/.*.(js|jsx)$", "rootDir": ".", "moduleNameMapper": { "\.css$": "identity-obj-proxy" }, "globals": { "ts-jest": { "isolatedModules": true } }, "moduleDirectories": [ "js", ".", "node_modules" ] },

example.test.js import 'regenerator-runtime/runtime'; import configureMockStore from 'redux-mock-store'; import thunk from 'redux-thunk'; const fetchMock = require('fetch-mock'); import { getEntityItems } from '../../src/actions/entity1';

const middlewares = [thunk]; const mockStore = configureMockStore(middlewares); global.requestURI = ''; const store = mockStore({}); const root = '/endpoint';

const testHelper = (description, path, query_params = {}) => { it(description, () => { fetchMock.getOnce( path, { body: { interactions: [] }, headers: { 'content-type': 'application/json' } } ); return store.dispatch(getEntityItems(query_params)).then(() => { expect(fetchMock.called(path)).toBe(true); }); }); };

describe('GET entites query parameters', () => { afterEach(fetchMock.reset());

testHelper('accepts an array of ids', root.concat('&ids=0,1,2'), { ids: [0, 1, 2] }); });

I have been trying to figure out why i am getting the above error; No Luck! TIA :)

brunouber commented 1 month ago

I still can reproduce this issue, more details here.