Mastering React Test-Driven Development - Second Edition: Build simple and maintainable web apps with React, Redux, and GraphQL

Irvine, Daniel

  • 出版商: Packt Publishing
  • 出版日期: 2022-09-30
  • 售價: $1,690
  • 貴賓價: 9.5$1,606
  • 語言: 英文
  • 頁數: 564
  • 裝訂: Quality Paper - also called trade paper
  • ISBN: 1803247126
  • ISBN-13: 9781803247120
  • 相關分類: Web APIReactTDD 測試導向開發
  • 海外代購書籍(需單獨結帳)
    無現貨庫存(No stock available)



Learn test-driven and behavior-driven development techniques that will give you greater confidence when building React applications


Key Features:

  • Explore the TDD process, how it works, and why it will help you write maintainable React apps
  • Develop a component testing framework from scratch, which will help you understand the mechanics of good unit testing
  • Reduce complexity by using unit tests and end-to-end acceptance tests to drive the design of your apps


Book Description:

Test-driven development (TDD) is a programming workflow that helps you build your apps by specifying behavior as automated tests. The TDD workflow future-proofs apps so that they can be modified without fear of breaking existing functionality. Another benefit of TDD is that it helps software development teams communicate their intentions more clearly, by way of test specifications.

This book teaches you how to apply TDD when building React apps. You'll create a sample app using the same React libraries and tools that professional React developers use, such as Jest, React Router, Redux, Relay (GraphQL), Cucumber, and Puppeteer. The TDD workflow is supported by various testing techniques and patterns, which are useful even if you're not following the TDD process. This book covers these techniques by walking you through the creation of a component test framework. You'll learn automated testing theory which will help you work with any of the test libraries that are in standard usage today, such as React Testing Library. This second edition has been revised with a stronger focus on concise code examples and has been fully updated for React 18.

By the end of this TDD book, you'll be able to use React, Redux, and GraphQL to develop robust web apps.


What You Will Learn:

  • Build test-driven applications using React 18 and Jest
  • Understand techniques and patterns for writing great automated tests
  • Use test doubles and mocks effectively
  • Test-drive browser APIs, including the Fetch API and the WebSocket API
  • Integrate with libraries such as React Router, Redux, and Relay (GraphQL)
  • Use Cucumber.js and Puppeteer to build Behaviour- Driven Development (BDD) style tests for your applications
  • Build and test async Redux code using redux-saga and expect-redux


Who this book is for:

This book is for frontend developers who are looking to improve their testing practices and increase the quality and maintainability of their applications. To make the most of this book, you'll need knowledge of the JavaScript programming language.




- 探索TDD過程,了解其工作原理以及為什麼它有助於編寫可維護的React應用程序。
- 從頭開始開發一個組件測試框架,這將幫助您理解良好單元測試的機制。
- 通過使用單元測試和端到端接受測試來驅動應用程序設計,從而降低複雜性。



本書教您如何在構建React應用程序時應用TDD。您將使用與專業React開發人員相同的React庫和工具創建一個示例應用程序,例如Jest、React Router、Redux、Relay(GraphQL)、Cucumber和Puppeteer。TDD工作流程支持各種測試技術和模式,即使您不遵循TDD過程,這些技術和模式也很有用。本書通過引導您創建一個組件測試框架來介紹這些技術。您將學習自動化測試理論,這將幫助您使用當今常用的任何測試庫,例如React Testing Library。本書第二版更加注重簡潔的代碼示例,並已完全更新為React 18。



- 使用React 18和Jest構建測試驅動的應用程序。
- 了解編寫優秀自動化測試的技巧和模式。
- 有效使用測試替身和模擬。
- 測試驅動瀏覽器API,包括Fetch API和WebSocket API。
- 整合React Router、Redux和Relay(GraphQL)等庫。
- 使用Cucumber.js和Puppeteer為應用程序構建行為驅動開發(BDD)風格的測試。
- 使用redux-saga和expect-redux構建和測試異步Redux代碼。



Daniel Irvine is a UK-based software consultant. He helps businesses simplify their existing codebases and assists dev teams in improving the quality of their software using eXtreme programming (XP) practices. He has been coaching developers for many years and co-founded the Queer Code London meetup.


Daniel Irvine 是一位位於英國的軟體顧問。他協助企業簡化現有的程式碼庫,並協助開發團隊透過極限程式設計(XP)實踐來提升軟體品質。多年來,他一直在指導開發人員,並共同創辦了 Queer Code London meetup。


  1. First Steps with Test-Driven Development
  2. Rendering Lists and Detail Views
  3. Refactoring the Test Suite
  4. Test-Driving Data Input
  5. Adding Complex Form Interactions
  6. Exploring Test Doubles
  7. Testing useEffect and Mocking Components
  8. Building an Application Component
  9. Form Validation
  10. Filtering and Searching Data
  11. Test-Driving React Router
  12. Test-Driving Redux
  13. Test-Driving GraphQL
  14. Building a Logo Interpreter
  15. Adding Animation
  16. Working with WebSockets
  17. Writing Your First Cucumber Test
  18. Adding Features Guided by Cucumber Tests
  19. Understanding TDD in the Wider Testing Landscape


  1. 測試驅動開發的第一步

  2. 渲染列表和詳細視圖

  3. 重構測試套件

  4. 測試驅動數據輸入

  5. 添加複雜的表單交互

  6. 探索測試替身

  7. 測試 useEffect 和模擬組件

  8. 構建應用組件

  9. 表單驗證

  10. 數據過濾和搜索

  11. 測試驅動 React Router

  12. 測試驅動 Redux

  13. 測試驅動 GraphQL

  14. 構建一個 Logo 解釋器

  15. 添加動畫

  16. 使用 WebSockets

  17. 撰寫第一個 Cucumber 測試

  18. 根據 Cucumber 測試添加功能

  19. 在廣泛的測試環境中理解測試驅動開發