Testing in JavaScript
218 pages
English
PDF
4.4

Testing in JavaScript

Testing in JavaScript

Author:

Year:

Summary:

This book is a practical guide to testing JavaScript applications in the Node.js environment. It is intended for developers who already have basic knowledge of JavaScript and want to master modern approaches to code quality assurance. Unlike many theoretical materials, the book focuses on real-world scenarios and tools used in production projects.

The reader will learn how to set up a test environment using Jest, Mocha, and Chai, and how to write unit, integration, and end-to-end tests. Special attention is paid to testing asynchronous code, working with databases, and external APIs. The book covers testing patterns, mock objects, spy functions, and stubs. Separate chapters are dedicated to testing Express applications, WebSocket connections, and MongoDB databases.

Chapter contents:
1. Introduction to testing: why and when to test
2. Tools: Jest, Mocha, Chai, Sinon
3. Unit tests: isolation and mock objects
4. Testing asynchronous code: callbacks, promises, async/await
5. Integration tests: working with databases and APIs
6. Testing Express applications: routes, middleware, errors
7. E2E testing with Puppeteer and Playwright
8. Continuous integration: GitHub Actions, CircleCI
9. TDD and BDD: practical examples
10. Security and performance testing

Why you should read this book: it is written by a practicing developer with 10 years of experience, contains ready-to-use code examples and real-world cases from commercial projects. You will not only learn the theory but will also be able to immediately apply the acquired knowledge in your work. The book is relevant for Node.js 16+ and all modern testing frameworks.

Recommendations