- 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
推薦閱讀
- Unity Virtual Reality Projects
- PHP 編程從入門到實踐
- PHP+MySQL+Dreamweaver動態網站開發實例教程
- Learning Three.js:The JavaScript 3D Library for WebGL
- Teaching with Google Classroom
- 蘋果的產品設計之道:創建優秀產品、服務和用戶體驗的七個原則
- Access 2010數據庫應用技術實驗指導與習題選解(第2版)
- Java編程從入門到精通
- 從程序員角度學習數據庫技術(藍橋杯軟件大賽培訓教材-Java方向)
- Python Programming for Arduino
- Qt 4開發實踐
- 快樂編程:青少年思維訓練
- 大規模語言模型開發基礎與實踐
- Java RESTful Web Service實戰
- Scala編程(第4版)