Open puzzledbytheweb opened 5 years ago
Do you have a simple setup on how to replicate?
I have the same error.
package versions:
jest: v24.9.0
jest-fetch-mock: v2.1.2
jest.config.js (left details out, can reproduce with just this)
module.exports = {
globalSetup: './tests/jest-setup.js'
tests/jest-setup.js
const fetch = require('jest-fetch-mock')
// details left out - error throw inside `jest-fetch-mock` with just this
The error occurs inside jest-fetch-mock/src/index.js
on line 49. There is a reference to jest
but no import for it.
How are you running your tests? jest
is a global that's available whenever a test is being run with jest
I have a test
run-script in package.json
file that runs jest
. I use yarn
instead of npm
, but not sure if that makes a difference. Running the local jest
directly (./node_modules/.bin/jest
) gives me the exact same error.
Hello everyone. I'm so sorry I did not respond, I had this error so long ago I don't even know in which context it appeared :/. Sorry, I hope you guys can solve it :/
I just ran into this error and fixed it. In my situation I have ejected from CRA so I have ./scripts/test.js
that my package.json
scripts use to run tests. I had first put the
global.fetch = require('jest-fetch-mock');
in there. It actually needed to go into ./config/jest/setupTests.js
which is what jest is configured to use as a setup file.
I have the same error.
package versions:
jest: v24.9.0 jest-fetch-mock: v2.1.2
jest.config.js (left details out, can reproduce with just this)
module.exports = { globalSetup: './tests/jest-setup.js'
tests/jest-setup.js
const fetch = require('jest-fetch-mock') // details left out - error throw inside `jest-fetch-mock` with just this
The error occurs inside
jest-fetch-mock/src/index.js
on line 49. There is a reference tojest
but no import for it.
seems it should be
setupFiles: [
'./__test__/jest-setup.ts'
],
not globalSetup
I had this issue. All I had to do to fix it was quit and restart the test watcher. It was caused because I reinstalled node_modules while the watcher was running.
Had this after upgrading to Next 11. My setup had collocated test & implementation files which I had working via webpack's IgnoreLoader plugin. This plugin had a breaking change in Webpack 5.
config.plugins.push(new webpack.IgnorePlugin(/\.(e2e|spec).(ts|tsx)$/))
to
config.plugins.push(new webpack.IgnorePlugin({ resourceRegExp: /\.(e2e|spec).(ts|tsx)$/ }))
While trying to use this package i receive this error:
Do you have any idea how to fix this? Is this related to this project peer-dependencies?
Thanks in advance!