wheresrhys/fetch-mock-jest

TypeError: debug is not a function

Opened this issue · 7 comments

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

image

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

image

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

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

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.

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

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 :)

I still can reproduce this issue, more details here.