首页 > 其他 > 详细

React Testing Library(RTL)

时间:2021-01-12 09:45:53      阅读:25      评论:0      收藏:0      [点我收藏+]

Basic concept

React beginners often confuse the tools for testing in React. React Testing Library is not an alternative to Jest, because they need each other and every one of them has a clear task.

If you are using create-react-app, Jest (and React Testing Library) comes by default with the installation. Let‘s look at the following functions for your tests:

describe(‘my function or component‘, () => {
  test(‘does the following‘, () => {
      expect(2 + 4).toBe(6);
  });
});
  • Whereas the describe-block is the test suite

  • the test-block (which also can be named it instead of test) is the test case. A test suite can have multiple test cases and a test case doesn‘t have to be in a test suite.

  • What you put into the test cases are called assertions (e.g. expect in Jest) which either turn out to be successful (green) or erroneous (red).

React Testing Library(RTL)

原文:https://www.cnblogs.com/testopsfeng/p/14265218.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!