为什么即使这些调用之间没有任何动作或状态更改,queryByText
第二次调用相同的函数也会给出结果?null
it('should ...', async () => {
...
userEvent.upload(fileInput, file);
await waitFor(() => expect(screen.queryByText('Import')).not.toBeDisabled());
userEvent.click(screen.queryByText('Import')); // <- fails here cause the same as above queryByText returns null
// Type 'null' is not assignable to type 'TargetElement'
...
});
如果我把screen.debug()
,await waitFor
它说按钮肯定在那里: