You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't reproduce it on a different (or simpler) project than the one where is currently occurring.
Expected behavior
Jest runs test correctly.
Actual behavior
TypeError: debug is not a function
> 5 | import fetchMock from 'fetch-mock';
| ^
6 |
7 | import { render, screen, waitFor } from '@testing-library/react';
8 | import userEvent from '@testing-library/user-event';
at newDebug (node_modules/fetch-mock/cjs/lib/debug.js:14:5)
at Object.<anonymous> (node_modules/fetch-mock/cjs/lib/debug.js:19:1)
at Object.<anonymous> (node_modules/fetch-mock/cjs/lib/index.js:1:121)
at Object.<anonymous> (node_modules/fetch-mock/cjs/server.js:15:19)
at Object.<anonymous> (frontend/js/demo.test.tsx:5:1)
Additional context
You won't like this.
I've read your submission guidelines, but this time I can't (as I am not be able to) recreate a simple test scenario...
I understand this is a bummer, but please, before closing the issue, read it and you'll understand why is that.
You might be still be able to point me in the right direction.
I'm the only person in my team (yay) who could reproduce it, despite having all the same node version and dependencies installed.
We have several tests files.
Some of these use fetch-mock (latest version).
The problem appears only in the files using fetch-mock.
TypeError: debug is not a function
> 5 | import fetchMock from 'fetch-mock';
| ^
6 |
7 | import { render, screen, waitFor } from '@testing-library/react';
8 | import userEvent from '@testing-library/user-event';
at newDebug (node_modules/fetch-mock/cjs/lib/debug.js:14:5)
at Object.<anonymous> (node_modules/fetch-mock/cjs/lib/debug.js:19:1)
at Object.<anonymous> (node_modules/fetch-mock/cjs/lib/index.js:1:121)
at Object.<anonymous> (node_modules/fetch-mock/cjs/server.js:15:19)
at Object.<anonymous> (frontend/js/demo.test.tsx:5:1)
debug is defined as const debug = require('debug'); and it's correctly installed in my repository.
In fact, I've added some logs here and there, and it's also executed.
What is most surprising to me is what I get in the console when I log the content of debug:
It's an object that looks like something that makes sense in our domain, but it doesn't have nothing to do with jest, or jest-mock.
I imagined this could be caused by some symbol resolution conflict, but what makes this hard to accept is that if i perform a string search in the repository for any of the labels in the object (eg "journal_benchmarking_dev") I can't find any match.
I understand the Jest run tests on the source files, performing JIT compilation... is there any way to inspect the actual source code Jest is using for the test?
Do you have any idea what might be causing this problem, or how to fix it?
I've already tried almost everything:
If i replace const debug = require('debug'); in node_modules/fetch-mock with const debug = require('abs/path/to/debug'); then everything works fine.
The problem seems unrelated to fetch-mock. In fact, if I inspect debug in a file that is not using fetch-mock I can still see the wrong value... but this doesn't break the test cause debug is not used unless also fetch-mock is used.
Version
29.7.0
Steps to reproduce
I can't reproduce it on a different (or simpler) project than the one where is currently occurring.
Expected behavior
Jest runs test correctly.
Actual behavior
Additional context
You won't like this.
I've read your submission guidelines, but this time I can't (as I am not be able to) recreate a simple test scenario...
I understand this is a bummer, but please, before closing the issue, read it and you'll understand why is that.
You might be still be able to point me in the right direction.
I'm the only person in my team (yay) who could reproduce it, despite having all the same node version and dependencies installed.
We have several tests files.
Some of these use fetch-mock (latest version).
The problem appears only in the files using fetch-mock.
debug
is defined asconst debug = require('debug');
and it's correctly installed in my repository.In fact, I've added some logs here and there, and it's also executed.
What is most surprising to me is what I get in the console when I log the content of
debug
:It's an object that looks like something that makes sense in our domain, but it doesn't have nothing to do with jest, or jest-mock.
I imagined this could be caused by some symbol resolution conflict, but what makes this hard to accept is that if i perform a string search in the repository for any of the labels in the object (eg "journal_benchmarking_dev") I can't find any match.
I understand the Jest run tests on the source files, performing JIT compilation... is there any way to inspect the actual source code Jest is using for the test?
Do you have any idea what might be causing this problem, or how to fix it?
I've already tried almost everything:
Environment
The text was updated successfully, but these errors were encountered: