react-testing-library,检查是否调用了组件方法

时间:2019-06-06 19:34:34

标签: reactjs react-testing-library

使用'@testing-library/react'

提供了以下组件:

const Home = () => {
   const submit = () => console.log('submit clicked');

   return (
     <div>
       Home
      <Button
        onClick={submit}
      >
        Submit
      </Button>
     </div>
   )
}

要完成下面的测试,必须添加什么断言?

it('reacts to a submit event', async () => {
    const { getByText } = render(<Home />);

    fireEvent.click(getByText(/submit/i));
  })

0 个答案:

没有答案