The Ultimate Guide to unit testing in JavaScript!
A Thread...
https://abs.twimg.com/emoji/v2/... draggable="false" alt="🧵" title="Thread" aria-label="Emoji: Thread">
A Thread...
A unit test should test the behavior of a unit of work.
Unit tests are isolated and independent of each other.
- Any given behaviour should be specified in one and only one test
- The execution/order of execution of one test cannot affect the others
- Repeatable
- Fast
Unit tests are isolated and independent of each other.
- Any given behaviour should be specified in one and only one test
- The execution/order of execution of one test cannot affect the others
- Repeatable
- Fast
Ultimate Guidelines Which Helped Me a Lot.
- Whenever possible, use TDD
- Structure your tests properly
- Name your tests properly
- Don& #39;t comment out tests
- Avoid logic in your tests
- Don& #39;t write unnecessary expectations
- Know your testing framework API
- Whenever possible, use TDD
- Structure your tests properly
- Name your tests properly
- Don& #39;t comment out tests
- Avoid logic in your tests
- Don& #39;t write unnecessary expectations
- Know your testing framework API
- Consider using factory functions in the tests
- Don& #39;t test multiple concerns in the same test
- Cover the general case and the edge cases
- Test the behavior, not the internal implementation
- Don& #39;t mock everything
- Create new tests for every defect
- Test simple actions
- Don& #39;t test multiple concerns in the same test
- Cover the general case and the edge cases
- Test the behavior, not the internal implementation
- Don& #39;t mock everything
- Create new tests for every defect
- Test simple actions
- Review test code first
- When applying TDD, always start by writing the simplest failing test
- When applying TDD, always make small steps in each test-first cycle
- Properly setup the actions that apply to all the tests involved
Remember
https://abs.twimg.com/emoji/v2/... draggable="false" alt="👉" title="Rückhand Zeigefinger nach rechts" aria-label="Emoji: Rückhand Zeigefinger nach rechts"> "Unit tests are code too"
- When applying TDD, always start by writing the simplest failing test
- When applying TDD, always make small steps in each test-first cycle
- Properly setup the actions that apply to all the tests involved
Remember
For more details checkout below the blog post.
The Ultimate Guide to unit testing in JavaScript!
from @hashnode https://codelifefitness.hashnode.dev/the-ultimate-guide-to-unit-testing-in-javascript">https://codelifefitness.hashnode.dev/the-ultim...
The Ultimate Guide to unit testing in JavaScript!
from @hashnode https://codelifefitness.hashnode.dev/the-ultimate-guide-to-unit-testing-in-javascript">https://codelifefitness.hashnode.dev/the-ultim...