If I remove the nock import I won't get an error message. I've already npm installed nock.
Test file
import configureMockStore from 'redux-mock-store'
import { promiseHandler } from '../middleware'
import * as actions from './index'
import nock from 'nock'
import expect from 'expect'
const middlewares = [promiseHandler]
const mockStore = configureMockStore(middlewares)
Error Message
FAIL src/actions/index.test.js
Runtime Error
- TypeError: debug is not a function
at overrideClientRequest (node_modules/nock/lib/intercept.js:221:3)
at activate (node_modules/nock/lib/intercept.js:320:3)
at Object.<anonymous> (node_modules/nock/lib/intercept.js:383:1)
at Runtime._execModule (node_modules/jest-cli/src/Runtime/Runtime.js:261:17)
at Object.<anonymous> (node_modules/nock/lib/recorder.js:6:17)
at Object.<anonymous> (node_modules/nock/index.js:1:135)
at Object.<anonymous> (src/actions/index.test.js:4:39)
at jasmine2 (node_modules/jest-jasmine2/src/index.js:252:16)
at handle (node_modules/worker-farm/lib/child/index.js:41:8)
at process.<anonymous> (node_modules/worker-farm/lib/child/index.js:47:3)
at emitTwo (events.js:100:13)
at process.emit (events.js:185:7)
at handleMessage (internal/child_process.js:718:10)
at Pipe.channel.onread (internal/child_process.js:444:11)
I'm having the same problem. If you're using Jest, I believe you need to unmock these modules before using them because Jest will automock everything.
At the top of your file, add:
jest.unmock('nock');
jest.unmock('redux-mock-store');
jest.unmock('redux-thunk');
Confirming this was the issue.
On Mon, Jun 27, 2016 at 12:35 PM, Danny [email protected] wrote:
I'm having the same problem. If you're using Jest, I believe you need to
unmock these modules before using them because Jest will automock
everything.At the top of your file, add:
jest.unmock('nock');
jest.unmock('redux-mock-store');
jest.unmock('redux-thunk');—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/node-nock/nock/issues/584#issuecomment-228851326, or mute
the thread
https://github.com/notifications/unsubscribe/AS016_Y3IuGrCnLQFOse-kcX3cRaYZFEks5qQCYfgaJpZM4I226_
.
Also confirming I was able to resolve this by putting this my package.json file:
"jest": {
"unmockedModulePathPatterns": [
"<rootDir>/node_modules/nock",
"<rootDir>/node_modules/redux-thunk",
"<rootDir>/node_modules/redux-mock-store",
]
}
Anyone have this issue with jasmine?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We try to do our best, but nock is maintained by volunteers and there is only so much we can do at a time. Thank you for your contributions.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you!
Most helpful comment
Also confirming I was able to resolve this by putting this my package.json file: