我有新的反应:)
如果我的组件渲染如下所示:
render() {
return (
<object-search className="m-t-xs">
<div className="stats-title pull-left">
<h4>Object Search</h4>
我的测试是:
beforeEach(() => {
component = TestUtils.renderIntoDocument(<ObjectSearch {...props}/>);
renderedDOM = () => ReactDOM.findDOMNode(component);
});
it('should render with the correct DOM', () => {
const parent = renderedDOM();
expect(parent.tagName).toBe('OBJECT-SEARCH');
expect(parent.children.length).toBe(7);
expect(parent.classList[0]).toEqual('m-t-xs');
})
为什么我看到一个空的classList属性?
Home page ObjectSearch Rendering of ObjectSearch on componentDidMount should render with the correct DOM FAILED
Expected '' to equal 'm-t-xs'.
注意:使用karma test runner和jasmine