错误呈现“在所有”之前勾掉FAILED - React + Karma

时间:2017-08-14 12:42:47

标签: reactjs unit-testing react-redux karma-runner chai

我使用Karma在React应用程序中运行我的测试用例但在后续文件中出错,before语句没有按预期执行错误描述也在下面提到:

/* eslint-disable no-undef */
import Heading from 'lib/component/common/Heading/Heading';
import renderAndReturnOutput from '../../../testutils/renderAndReturnOutput.js';
import {findType} from '../../../testutils/shallowHelpers.js';
import { assert } from 'chai';
describe('component/common/Heading', () => {
    describe('render', () => {
        let output,
            props;
        before(() => { 
            props = {};
            output = renderAndReturnOutput(Heading, props).output;
        });
        it('should load Heading view', () => {  
            assert.ok(findType(output, 'div'));
        });     
    });  
});
/* eslint-enable no-undef */

错误说明:

PhantomJS 2.1.1 (Windows 7 0.0.0) component/common/Button render "before all" hook FAILED
        null is not an object (evaluating 'getReactDOM().__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED')
        getReactTestUtils@C:/Vishal/UI/poc1/risk-oda/node_modules/react/dist/react-with-addons.js:476:25
        get@C:/Vishal/UI/poc1/node_modules/react/dist/react-with-addons.js:3197:58
        default@C:/Vishal/UI/poc1/testlib/unit/testutils/renderAndReturnOutput.js:4:57
        C:/Vishal/UI/poc1/testlib/unit/component/common/Button/Button-test.js:16:62

package.json的片段以突出显示所使用的NPM版本,如下所述:

"karma": "^0.13.3",
"react": "^15.1.0",
"react-addons-test-utils": "^15.3.1",
"react-dom": "^15.1.0",
"react-redux": "~4.4.5",
"react-shallow-renderer-helpers": "^2.0.2",
"redux": "~3.5.2"

知道为什么会这样吗?

0 个答案:

没有答案