运行npmtesting时导入Nock npm模块会产生错误

如果我删除了nock导入,我将不会收到错误消息。 我已经安装了npm npm。

testing文件

 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) 

错误信息

  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) 

我没有意识到我的项目正在使用Jesttesting框架,随后通过执行jest.unmock('nock');来模块需要“解锁” jest.unmock('nock'); 在导入之前。