0%

Testing JavaScript Applications teaches you how to implement an automated testing plan for JavaScript-based web applications. It describes practical testing strategies, covers useful tools and libraries, and explains how to foster a culture of quality. In this clearly-written, example-rich book, you’ll explore approaches for both backend and frontend applications and learn how to validate your software much more quickly and reliably.

Table of Contents

  1. inside front cover
  2. Testing JavaScript Applications
  3. Copyright
  4. dedication
  5. contents
  6. front matter
    1. preface
    2. acknowledgments
    3. about this book
    4. Who should read this book
    5. How this book is organized: A roadmap
    6. About the code
    7. System requirements
    8. liveBook discussion forum
    9. about the author
    10. about the cover illustration
  7. Part 1. Testing JavaScript applications
  8. 1 An introduction to automated testing
    1. 1.1 What is an automated test?
    2. 1.2 Why automated tests matter
    3. 1.2.1 Predictability
    4. 1.2.2 Reproducibility
    5. 1.2.3 Collaboration
    6. 1.2.4 Speed
    7. Summary
  9. 2 What to test and when?
    1. 2.1 The testing pyramid
    2. 2.2 Unit tests
    3. 2.3 Integration tests
    4. 2.4 End-to-end tests
    5. 2.4.1 Testing HTTP APIs
    6. 2.4.2 Testing GUIs
    7. 2.4.3 Acceptance tests and end-to-end tests are not the same
    8. 2.5 Exploratory testing and the value of QA
    9. 2.6 Tests, cost, and revenue
    10. Summary
  10. Part 2. Writing tests
  11. 3 Testing techniques
    1. 3.1 Organizing test suites
    2. 3.1.1 Breaking down tests
    3. 3.1.2 Parallelism
    4. 3.1.3 Global hooks
    5. 3.1.4 Atomicity
    6. 3.2 Writing good assertions
    7. 3.2.1 Assertions and error handling
    8. 3.2.2 Loose assertions
    9. 3.2.3 Using custom matchers
    10. 3.2.4 Circular assertions
    11. 3.3 Test doubles: Mocks, stubs, and spies
    12. 3.3.1 Mocking imports
    13. 3.4 Choosing what to test
    14. 3.4.1 Don’t test third-party software
    15. 3.4.2 To mock, or not to mock: That’s the question
    16. 3.4.3 When in doubt, choose integration tests
    17. 3.5 Code coverage
    18. 3.5.1 Automated coverage reports
    19. 3.5.2 Coverage types
    20. 3.5.3 What coverage is good for and what it isn’t
    21. Summary
  12. 4 Testing backend applications
    1. 4.1 Structuring a testing environment
    2. 4.1.1 End-to-end testing
    3. 4.1.2 Integration testing
    4. 4.1.3 Unit testing
    5. 4.2 Testing HTTP endpoints
    6. 4.2.1 Testing middleware
    7. 4.3 Dealing with external dependencies
    8. 4.3.1 Integrations with databases
    9. 4.3.2 Integrations with other APIs
    10. Summary
  13. 5 Advanced backend testing techniques
    1. 5.1 Eliminating nondeterminism
    2. 5.1.1 Parallelism and shared resources
    3. 5.1.2 Dealing with time
    4. 5.2 Reducing costs while preserving quality
    5. 5.2.1 Reducing overlap between tests
    6. 5.2.2 Creating transitive guarantees
    7. 5.2.3 Turning assertions into preconditions
    8. Summary
  14. 6 Testing frontend applications
    1. 6.1 Introducing JSDOM
    2. 6.2 Asserting on the DOM
    3. 6.2.1 Making it easier to find elements
    4. 6.2.2 Writing better assertions
    5. 6.3 Handling events
    6. 6.4 Testing and browser APIs
    7. 6.4.1 Testing a localStorage integration
    8. 6.4.2 Testing a History API integration
    9. 6.5 Dealing with WebSockets and HTTP requests
    10. 6.5.1 Tests involving HTTP requests
    11. 6.5.2 Tests involving WebSockets
    12. Summary
  15. 7 The React testing ecosystem
    1. 7.1 Setting up a test environment for React
    2. 7.1.1 Setting up a React application
    3. 7.1.2 Setting up a testing environment
    4. 7.2 An overview of React testing libraries
    5. 7.2.1 Rendering components and the DOM
    6. 7.2.2 React Testing Library
    7. 7.2.3 Enzyme
    8. 7.2.4 The React test renderer
    9. Summary
  16. 8 Testing React applications
    1. 8.1 Testing component integration
    2. 8.1.1 Stubbing components
    3. 8.2 Snapshot testing
    4. 8.2.1 Snapshots beyond components
    5. 8.2.2 Serializers
    6. 8.3 Testing styles
    7. 8.4 Component-level acceptance tests and component stories
    8. 8.4.1 Writing stories
    9. 8.4.2 Writing documentation
    10. Summary
  17. 9 Test-driven development
    1. 9.1 The philosophy behind test-driven development
    2. 9.1.1 What test-driven development is
    3. 9.1.2 Adjusting the size of your iterations
    4. 9.1.3 Why adopt test-driven development?
    5. 9.1.4 When not to apply test-driven development
    6. 9.2 Writing a JavaScript module using TDD
    7. 9.3 Testing top-down versus testing bottom-up
    8. 9.3.1 What bottom-up and top-down testing mean
    9. 9.3.2 How top-down and bottom-up approaches impact a test-driven workflow
    10. 9.3.3 The pros and cons of bottom-up versus top-down approaches
    11. 9.4 Balancing maintenance costs, delivery speed, and brittleness
    12. 9.4.1 Test-driven implementation
    13. 9.4.2 Test-driven maintenance
    14. 9.5 Setting up an environment for TDD to succeed
    15. 9.5.1 Teamwide adoption
    16. 9.5.2 Keeping distinct lanes
    17. 9.5.3 Pairing
    18. 9.5.4 Supplementary testing
    19. 9.6 TDD, BDD, validations, and specificationsBDD (behavior-driven development)
    20. Summary
  18. 10 UI-based end-to-end testing
    1. 10.1 What are UI-based end-to-end tests?
    2. 10.2 When to write each type of test
    3. 10.2.1 UI-based end-to-end tests
    4. 10.2.2 Pure end-to-end tests
    5. 10.2.3 Pure UI tests
    6. 10.2.4 A note on acceptance testing and this chapter’s name
    7. 10.3 An overview of end-to-end testing tools
    8. 10.3.1 Selenium
    9. 10.3.2 Puppeteer
    10. 10.3.3 Cypress
    11. 10.3.4 When to choose Cypress
    12. Summary
  19. 11 Writing UI-based end-to-end tests
    1. 11.1 Your first UI-based end-to-end tests
    2. 11.1.1 Setting up a test environment
    3. 11.1.2 Writing your first tests
    4. 11.1.3 Sending HTTP requests
    5. 11.1.4 Sequencing actions
    6. 11.2 Best practices for end-to-end-tests
    7. 11.2.1 Page objects
    8. 11.2.2 Application actions
    9. 11.3 Dealing with flakiness
    10. 11.3.1 Avoiding waiting for fixed amounts of time
    11. 11.3.2 Stubbing uncontrollable factors
    12. 11.3.3 Retrying tests
    13. 11.4 Running tests on multiple browsers
    14. 11.4.1 Using a testing framework to run tests within a browser
    15. 11.4.2 Running UI-based tests in multiple browsers
    16. 11.5 Visual regression tests
    17. Summary
  20. Part 3. Business impact
  21. 12 Continuous integration and continuous delivery
    1. 12.1 What are continuous integration and continuous delivery?
    2. 12.1.1 Continuous integration
    3. 12.1.2 Continuous delivery
    4. 12.2 The role of automated tests in a CI/CD pipeline
    5. 12.3 Version-control checks
    6. Summary
  22. 13 A culture of quality
    1. 13.1 Using type systems to make invalid states unrepresentable
    2. 13.2 Reviewing code to catch problems machines can’t
    3. 13.3 Using linters and formatters to produce consistent code
    4. 13.4 Monitoring your systems to understand how they actually behave
    5. 13.5 Explaining your software with good documentation
    6. Summary
  23. index
  24. inside back cover
3.138.105.41