更新到 npm 3.3.12 后使用 Jest 进行单元测试时出错

Error in unit testing with Jest after updating to npm 3.3.12

我最近将我的项目更新到 node 5.1.0、npm 3.3.12 并更新了我所有的依赖项...现在我正在与一堆错误作斗争!

最初我在这个问题上遇到了同样的错误:https://github.com/facebook/jest/issues/554,很容易修复。

但是现在我得到了这个:

Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components).

Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

我的 package.json 中有这个:

"jest": {
    "collectCoverage": true,
    "testRunner": "./node_modules/jest-cli/src/testRunners/jasmine/jasmine2",
    "scriptPreprocessor": "./node_modules/babel-jest",
    "unmockedModulePathPatterns": [
        "./node_modules/es6-promise",
        "./node_modules/events",
        "./node_modules/fbjs",
        "./node_modules/flux",
        "./node_modules/history",
        "./node_modules/immutable",
        "./node_modules/lodash",
        "./node_modules/moment",
        "./node_modules/react",
        "./node_modules/react-addons-pure-render-mixin",
        "./node_modules/react-addons-test-utils",
        "./node_modules/react-d3",
        "./node_modules/react-dom",
        "./node_modules/react-modal",
        "./node_modules/react-router",
        "./node_modules/whatwg-fetch"
    ]
  }

我测试的相关部分是:

var ImageGallery = require('../../../app/components/image-gallery/image-gallery');
imageGalleryComponent = TestUtils.renderIntoDocument(
    <ImageGallery
        items={items}
        onSlide={onSlideMock}
        lazyLoad={false}
        showBullets={true}
        showThumbnails={true}
        showNav={true}
        slideInterval={4000}/>
);

有人 运行 了解这个问题吗?关于如何解决它的任何线索?

在我的代码中,我将 babel 与 "imports" 一起使用,所以问题是在测试中我也需要使用 "imports" 或者只是在末尾添加一个“.default” require 语句,像这样:

var ImageGallery = require('../../../app/components/image-gallery/image-gallery').default;