Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

TypeError: debug is not a function #25

Open
willxtong opened this issue Nov 24, 2020 · 7 comments
Open

TypeError: debug is not a function #25

willxtong opened this issue Nov 24, 2020 · 7 comments
Labels
bug Something isn't working types

Comments

@willxtong
Copy link

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

image

@willxtong
Copy link
Author

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

image

@wheresrhys
Copy link
Owner

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

@wheresrhys
Copy link
Owner

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

@gilbarbara
Copy link

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
Copy link
Owner

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

@wheresrhys wheresrhys reopened this Dec 19, 2020
@akarshan1996
Copy link

akarshan1996 commented Sep 20, 2021

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

@wheresrhys wheresrhys added bug Something isn't working types labels Jul 20, 2024
@brunouber
Copy link

I still can reproduce this issue, more details here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working types
Projects
None yet
Development

No branches or pull requests

5 participants