我是 Jest 和 Enzyme 测试的新手,我想知道为什么 find 函数不适用于 id。
//来自react的html,只是id增量所在的代码
<div className="App-body">
<div className="changePage">
<button className="Selections" onClick={this.decrementPage}>Previous</button>
<p className="changePageNumber">{this.state.page}</p>
<button className="Selections" id="increment" onClick={this.incrementPage}>Next</button>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
//测试
it('next page', () => {
const wrapper = shallow(<Home />)
const incrementPage = wrapper.find('#increment')
incrementPage.simulate('click')
const countState = wrapper.state().page
expect(countState).toEqual(2)
})Run Code Online (Sandbox Code Playgroud)
Method “simulate” is meant to be run on 1 node. 0 found instead.
Run Code Online (Sandbox Code Playgroud)
Method “simulate” is meant to be run on 1 node. 0 found instead.
Run Code Online (Sandbox Code Playgroud)