- Mastering React Test:Driven Development
- Daniel Irvine
- 78字
- 2021-06-24 14:45:03
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
推薦閱讀
- 大學計算機基礎(第二版)
- ASP.NET Web API:Build RESTful web applications and services on the .NET framework
- JavaScript百煉成仙
- C# 2012程序設計實踐教程 (清華電腦學堂)
- 高效微控制器C語言編程
- Mastering Spring MVC 4
- 面向對象程序設計(Java版)
- Yii Project Blueprints
- JBoss:Developer's Guide
- 后臺開發:核心技術與應用實踐
- Java Web應用開發項目教程
- 零基礎學HTML+CSS第2版
- Modernizing Legacy Applications in PHP
- 寫給青少年的人工智能(Python版·微課視頻版)
- Drupal 8 Development Cookbook(Second Edition)