整个错误和代码:https://gist.github.com/js08/1c80a53fe8666b2a207bf9d961bdaa3d
喜
错误
```js
1) "SportsTopPortion" Unit Tests native build env should render mobile built view:
AssertionError: expected { Object ($typeof, type, ...) } to deeply equal { Object ($typeof, type, ...) }
+ expected - actual
"_owner": [null]
"_store": {}
"key": [null]
"props": {
- "children": {
-
at Assertion.assertEqual (C:\sports-whole-package\node_modules\chai\lib\chai\core\assertions.js:455:19)
at Assertion.ctx.(anonymous function) [as equal] (C:\sports-whole-package\node_modules\chai\lib\chai\utils\addMethod.js:40:25)
at Context.<anonymous> (C:/codebase/sports-template-standard/test/components/SportsTopPortion/SportsTopPortion-unit-tests.js:105:60)
at callFn (C:\sports-whole-package\node_modules\mocha\lib\runnable.js:286:21)
at Test.Runnable.run (C:\sports-whole-package\node_modules\mocha\lib\runnable.js:279:7)
at Runner.runTest (C:\sports-whole-package\node_modules\mocha\lib\runner.js:421:10)
at C:\sports-whole-package\node_modules\mocha\lib\runner.js:528:12
at next (C:\sports-whole-package\node_modules\mocha\lib\runner.js:341:14)
at C:\sports-whole-package\node_modules\mocha\lib\runner.js:351:7
at next (C:\sports-whole-package\node_modules\mocha\lib\runner.js:283:14)
at Immediate._onImmediate (C:\sports-whole-package\node_modules\mocha\lib\runner.js:319:5)
```
test case
```js
import {expect} from 'chai';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import {SportsTopPortion} from '../../../src/components/sports-top-portion/sports-top-portion.jsx';
require('../../test-utils/dom');
describe('"sports-top-portion" Unit Tests', function() {
let shallowRenderer = TestUtils.createRenderer();
let sportsContentContainerLayout ='mobile';
let sportsContentContainerProfile = {'exists': 'hasSidebar'};
let sportsContentContainerAuthExchange = {hasValidAccessToken: true};
let sportsContentContainerHasValidAccessToken ='test';
describe('native build env', function() {
console.log("native build------->");
before(function() {
console.log("inside before------->");
process.env.sports_PLATFORM= 'mobile';
});
after(function() {
console.log("inside after------->");
delete process.env.sports_PLATFORM;
});
it('should render mobile built view', function() {
let testRenderer = new ReactTestRenderer(<SportsTopPortion sportsWholeFramework={sportsContentContainerLayout} sportsPlayers={sportsContentContainerProfile} sportsAuthentication={sportsContentContainerAuthExchange} sportsUpperBar={{activeSportsLink:'test'}} />);
let onClose = function() {
console.log("------------>bar");
};
let expected = (
<header role="banner">
<a href="/" className="sportsTopPortion-iconLink">
<img src="~^img,header-logo.svg~^" className="sportsTopPortion-icon" alt="sports Home"/>
</a>
<HeaderDropMask header={{activeMenu:'test'}} onClose={onClose} />
</header>
);
console.log(("testRenderer------->" + JSON.stringify(testRenderer.getRenderOutput())));
console.log(("expected------->" + JSON.stringify(expected)));
expect(testRenderer.getRenderOutput()).to.deep.equal(expected);
});
})
});
```