react-component / react-component/field-form
关于测试代码中使用simulate方法需要调用timeout的疑问
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1k
- Forks
- 286
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 1
Description
请教作者一个问题
我在看测试代码的时候发现
export default (timeout: number = 0) => {
return new Promise(resolve => {
setTimeout(resolve, timeout);
});
};
await changeValue(getField(wrapper), 'Bamboo');
wrapper.find('button').simulate('submit');
await timeout();
我自己在测试的时候发现如果不执行await timeout(),那么onFinish就不会被调用。
这是为什么呢
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with tests/common/timeout.ts and tests/index.test.js around lines 244-246. Trace the submit simulation and the timing of the onFinish callback, then check the related test setup and React event behavior. Done means documenting why await timeout() is required or confirming that the test can avoid it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- testing-qa
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100