Importing the Nock npm module creates error when running npm test
See original GitHub issueIf 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)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
Importing the Nock npm module creates error when running ...
I've already npm installed nock . Test file. import configureMockStore from 'redux-mock-store' import { promiseHandler } from ...
Read more >nock - npm
HTTP server mocking and expectations library for Node.js. Nock can be used to test modules that perform HTTP requests in isolation.
Read more >API mock testing with Nock for Node.js apps - LogRocket Blog
In this quick tutorial, learn how to make mock HTTP requests with Nock to test your Node.js application's API endpoints.
Read more >Testing Error Handling in node.js | by Lars Trieloff
json 's test script, I set up nyc , which generates test coverage reports with the following options: --reporter=text creates a nice textual...
Read more >Mocking External HTTP Requests in Node Tests with Nock
Avoid the challenges of testing Node.js code that depends on external services and APIs by using Nock to test HTTP requests in isolation....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Also confirming I was able to resolve this by putting this my package.json file:
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: