zoukankan      html  css  js  c++  java
  • [React Testing] Improve Test Confidence with the User Event Module

    The User Event module is part of the Testing Library family of tools and lets you fire events on DOM nodes that more closely resemble the way your users will interact with your elements. Let’s refactor our fire event usages to use that instead.

    import user from '@testing-library/user-event'
    
    test('v2: entering an invalid value shows an error message', () => {
      const { getByLabelText, getByRole } = render(<FavoriteNumber />)
      const input = getByLabelText(/favorite number/i)
      // simulate a user type on input
      user.type(input, '10')
      expect(getByRole('alert')).toHaveTextContent(/the number is invalid/i)
    })
  • 相关阅读:
    2020-08-20
    2020-08-19
    2020-08-14
    2020-08-13
    使用numpy实现机器学习模型
    分治法学习
    2020-08-09
    2020-08-02
    四月是你的谎言下载
    新博客
  • 原文地址:https://www.cnblogs.com/Answer1215/p/12810682.html
Copyright © 2011-2022 走看看