{"repo":"mawrkus/js-unit-testing-guide","free":true,"listed":false,"github":"https://github.com/mawrkus/js-unit-testing-guide","clone":"git clone https://github.com/mawrkus/js-unit-testing-guide.git","description":"📙 A guide to unit testing in Javascript","language":null,"stars":1963,"topics":["unit-testing","unit-test","tdd","katas","javascript","testing","best-practices"],"license":null,"category":"dev-tools","readme_excerpt":"A guide to unit testing in JavaScript This is a living document. New ideas are always welcome. Contribute: fork, clone, branch, commit, push, pull request. All the information provided has been compiled & adapted from many references, some of them cited at the end of the document. The guidelines are illustrated by my own examples, fruit of my personal experience writing and reviewing unit tests. Many thanks to all of the sources of information & contributors. 📅 Last edit: September 2025. 📖 Table of contents 1. General principles - Unit tests - Design principles 2. Guidelines - Whenever possible, use TDD - When applying TDD, always start by writing the simplest failing test - When applying TDD, always make baby steps in each cycle - Structure your tests properly - Name your tests properly - Use the Arrange-Act-Assert pattern - Avoid logic in your tests - Don't write unnecessary expectations - Test the behaviour, not the internal implementation - Consider using factory functions - Don't test multiple concerns in the same test - Cover the general case and the edge cases - Use dependency injection - Don't mock everything - Use realistic, production-like, data - Don't write unit tests for complex user interactions - Test simple user actions - Create new tests for every defect - Don't comment out tests - Know your testing framework API - Review test code first - Practice code katas, learn with pair programming 3. Resources 4. Translations 5. Contributors ⛩️ General principles Uni","default_branch":null,"files":null,"tree":[],"storefront":"/r/mawrkus","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/mawrkus/js-unit-testing-guide/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}