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

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
主站蜘蛛池模板: 隆尧县| 洪洞县| 恩施市| 广河县| 新乐市| 博野县| 安庆市| 新密市| 镇平县| 龙岩市| 西安市| 兴和县| 贵阳市| 灵寿县| 沂源县| 万安县| 常熟市| 柞水县| 云安县| 清丰县| 贵德县| 贞丰县| 嘉祥县| 成安县| 马关县| 吉木萨尔县| 黄龙县| 科技| 宁明县| 东至县| 灵武市| 老河口市| 五常市| 芒康县| 武陟县| 陇西县| 穆棱市| 巴中市| 梅河口市| 德阳市| 巴楚县|