The Ultimate Guide to Unit Testing in JavaScript.

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 behavior 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't comment out tests

- Avoid logic in your tests

- Don't write unnecessary expectations

- Know your testing framework API
- Consider using factory functions in the tests

- Don't test multiple concerns in the same test

- Cover the general case and the edge cases

- Test the behavior, not the internal implementation

- Don'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 set up the actions that apply to all the tests involved

Remember "Unit tests are code too"
Ok, I'll stop here.

Note: These guidelines can be leveraged for all the languages capable of unit testing.

Check out more in the blog post. ⬇

The Ultimate Guide to Unit Testing in JavaScript.

🔗 https://t.co/wvqfoN8ZdD

You May Also Like

MASTER THREAD on Short Strangles.

Curated the best tweets from the best traders who are exceptional at managing strangles.

• Positional Strangles
• Intraday Strangles
• Position Sizing
• How to do Adjustments
• Plenty of Examples
• When to avoid
• Exit Criteria

How to sell Strangles in weekly expiry as explained by boss himself. @Mitesh_Engr

• When to sell
• How to do Adjustments
• Exit


Beautiful explanation on positional option selling by @Mitesh_Engr
Sir on how to sell low premium strangles yourself without paying anyone. This is a free mini course in


1st Live example of managing a strangle by Mitesh Sir. @Mitesh_Engr

• Sold Strangles 20% cap used
• Added 20% cap more when in profit
• Booked profitable leg and rolled up
• Kept rolling up profitable leg
• Booked loss in calls
• Sold only


2nd example by @Mitesh_Engr Sir on converting a directional trade into strangles. Option Sellers can use this for consistent profit.

• Identified a reversal and sold puts

• Puts decayed a lot

• When achieved 2% profit through puts then sold