Testing JavaScript Applications
Lucas da Costa
  • MEAP began May 2020
  • Publication in Early 2021 (estimated)
  • ISBN 9781617297915
  • 325 pages (estimated)
  • printed in black & white

I was pleasantly surprised that a book about testing would be this much fun to read!

Rodney Weis
Automated testing will help you write high-quality software in less time, with more confidence, fewer bugs, and without constant manual oversight. Testing JavaScript Applications is a guide to building a comprehensive and reliable JS application testing suite, covering both how to write tests and how JS testing tools work under the hood. You’ll learn from Lucas de Costa, a core contributor to popular JS testing libraries, as he shares a quality mindset for making testing decisions that deliver a real contribution to your business. You’ll benefit from informative explanations and diagrams, easily-transferable code samples, and useful tips on using the latest and most consolidated libraries and frameworks of the JavaScript ecosystem.

About the Technology

No developer wants to waste time making sure every application feature still works whenever they push new code to production. Thankfully, automated testing delivers quick and precise feedback on whether your application still functions correctly every time you update it. With automated testing, you can validate your application with a single command—and unlike humans, machines don’t forget steps or make mistakes!

About the book

Testing JavaScript Applications is a guide to creating JavaScript tests that are targeted to your application’s specific needs. Dripping with the insight author Lucas da Costa has developed as a core contributor to some of the most popular JS testing libraries, this book offers dozens of detailed code samples that you can apply to your own projects. You’ll learn how to write tests for both backend and frontend applications, covering the full spectrum of testing types so you can pick an approach that’s right for you. Taking on the role of a developer for a bakery’s web store, you’ll learn to validate different aspects including databases, third-party services, and how to spin-up a real browser instance to interact with the entire application. All examples are delivered using the popular testing tool Jest and modern packages of the JavaScript ecosystem.
Table of Contents detailed table of contents

Part 1: Tests matter

1 An introduction to automated testing

1.1 What is an automated test?

1.2 Why automated tests matter

1.2.1 Predictability

1.2.2 Reproducibility

1.2.3 Collaboration

1.2.4 Speed

1.3 Summary

2 What to test and when

2.1 The testing pyramid

2.2 Unit Tests

2.3 Integration Tests

2.4 End-to-end tests

2.4.1 Testing HTTP APIs

2.4.2 Testing GUIs

2.4.3 Acceptance tests and End-to-end tests are not the same

2.5 Exploratory testing and the value of QA

2.6 Tests, cost, and revenue

2.7 Summary

Part 2: Writting tests

3 Testing techniques

3.1 Organising test suites

3.1.1 Breaking down tests

3.1.2 Parallelism

3.1.3 Global Hooks

3.1.4 Atomicity

3.2 Writing good assertions

3.2.1 Assertion counting

3.2.2 Loose assertions

3.2.3 Using custom matchers

3.2.4 Circular assertions

3.3 Test doubles: mocks, stubs, and spies

3.3.1 Mocking imports

3.4 Choosing what to test

3.4.1 Don’t test third-party software

3.4.2 To mock, or not to mock, that’s the question

3.4.3 When in doubt, choose integration tests

3.5 Summary

3.5.1 Organising test suites

3.5.2 Writing good assertions

3.5.3 Test doubles: mocks, stubs, and spies

3.5.4 Choosing what to test

4 Testing back-end applications

4.1 Structuring a testing environment

4.1.1 End-to-end testing

4.1.2 Integration testing

4.1.3 Unit testing

4.2 Testing HTTP endpoints

4.2.1 Testing middlewares

4.3 Dealing with external dependencies

4.3.1 Integrations with databases

4.3.2 Integrations with other APIs

4.4 Eliminating non-determinism

4.4.1 Parallelism and shared resources

4.4.2 Dealing with time

4.5 Reducing costs while preserving quality

4.5.1 Reducing overlap between tests

4.5.2 Creating transitive guarantees

4.5.3 Turning assertions into pre-conditions

4.6 Summary

5 Testing front-end applications

5.1 Introducing JSDOM

5.2 Asserting on the DOM

5.2.1 Making it easier to find elements

5.2.2 Writing better assertions

5.3 Handling events

5.4 Testing and browser APIs

5.4.1 Testing a localStorage integration

5.4.2 Testing a History API integration

5.5 Dealing with web sockets and HTTP requests

5.5.1 Tests involving HTTP requests

5.5.2 Tests involving web-sockets

5.6 Summary

6 Testing React components

7 Test-driven development

8 Testing tools in-depth

9 The testing mindset

10 End-to-end Testing

Part 3: Full stack considerations

11 Continuous Integration & Continuous Delivery

12 A culture of quality

Appendix

What's inside

  • Writing practical tests that make a real business contribution
  • Writing tests for both front-end and back-end applications
  • Managing the costs and complexity of your tests
  • Practicing test-driven development
  • Dealing with external dependencies, like databases or third-party APIs
  • Supporting tests by creating a "culture of quality"

About the reader

For junior JavaScript developers. No testing experience required.

About the author

Lucas da Costa is a core maintainer of Chai and Sinon.JS, two of the most popular testing tools in the JavaScript ecosystem. He has also contributed to Jest and other relevant open-source projects. Lucas is committed to a culture of sharing and has spoken at major software engineering conferences, including JSConf Colombia, FluentConf, HolyJS, CityJSConf London, and many others.

placing your order...

Don't refresh or navigate away from the page.
Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
print book $29.99 $49.99 pBook + eBook + liveBook
Additional shipping charges may apply
Testing JavaScript Applications (print book) added to cart
continue shopping
go to cart

eBook $24.99 $39.99 3 formats + liveBook
Testing JavaScript Applications (eBook) added to cart
continue shopping
go to cart

Prices displayed in rupees will be charged in USD when you check out.

FREE domestic shipping on three or more pBooks