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

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
主站蜘蛛池模板: 白沙| 丰宁| 水富县| 武清区| 左贡县| 怀安县| 和林格尔县| 宝兴县| 清水河县| 淮北市| 莱州市| 南安市| 垦利县| 开鲁县| 凤阳县| 赣榆县| 章丘市| 安丘市| 敖汉旗| 霍城县| 吐鲁番市| 卢湾区| 运城市| 榆中县| 陆河县| 夏津县| 兴城市| 怀柔区| 仁寿县| 厦门市| 邢台县| 桂平市| 奉贤区| 开远市| 德兴市| 镇雄县| 江津市| 华阴市| 白城市| 平远县| 腾冲县|