Tag: reactjs testutils

在基于jsdom的testing中调用setState导致“无法在工作线程中呈现标记”错误

我正在使用我自己的小型“虚拟浏览器”实用程序在jsdom下testing我的React组件。 工作得很好,直到我想setState 。 例如,当testing儿童年龄input控件时: describe('rendering according to the draft value', function () { var component; beforeEach(function () { component = TestUtils.renderIntoDocument( React.createElement(ChildrenInput, {value: []}) ); component.setState({draft: [{age: null}, {age: null}]}, done); }); it('overrides the value property for the count', function () { assert.strictEqual(component.refs.count.props.value, 2); }); it('overrides the value property for the ages', function () { […]