官术网_书友最值得收藏!

Writing great tests

The first test now looks like this:

it('renders the customer first name', () => {
customer = { firstName: 'Ashley' };
render(<Appointment customer={customer} />);
expect(container.textContent).toMatch('Ashley');
});

This is concise and clearly readable.

A good test has three distinct sections:

  • Arrange: Sets up test dependencies
  • Act: Executes production code under test
  • Assert: Checks expectations are met

A great test is not just good but is also the following:

  • Short
  • Descriptive
  • Independent of other tests
  • Has no side-effects
主站蜘蛛池模板: 海林市| 漳浦县| 托里县| 乌拉特前旗| 乐山市| 察雅县| 乐亭县| 客服| 城口县| 搜索| 宜章县| 明水县| 科技| 和平县| 建瓯市| 静海县| 乐东| 香格里拉县| 新化县| 二连浩特市| 屏东市| 垫江县| 航空| 达尔| 平和县| 镇安县| 阿拉善右旗| 文昌市| 漾濞| 揭阳市| 白沙| 乌拉特后旗| 瓦房店市| 武平县| 且末县| 磴口县| 额济纳旗| 宣城市| 汉沽区| 惠安县| 渑池县|