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

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
主站蜘蛛池模板: 泰顺县| 东丽区| 拉萨市| 襄垣县| 长治县| 通城县| 赣榆县| 平塘县| 台安县| 吉安市| 和硕县| 阜平县| 阿瓦提县| 鹤岗市| 喀喇沁旗| 水城县| 喀喇沁旗| 乐业县| 广平县| 武穴市| 错那县| 太原市| 西乌珠穆沁旗| 呈贡县| 抚顺县| 收藏| 平顺县| 区。| 蒙阴县| 兴国县| 平果县| 樟树市| 苍南县| 邯郸县| 合山市| 萍乡市| 乌拉特中旗| 山东| 诸暨市| 思茅市| 诏安县|