Labels

Sunday, June 20, 2021

JEST In-Time :)

 <<Under Construction>>

JEST, Mocha Chai Jasmine ..List of Unit Test JS Frameworks. It's really hard to believe what is better as one over has pros and cons over other.. 











 Well before we get to know what is best, first few baby steps in each.. 

Mocha: 

We all know Mocha Node.js unit testing frameworks, released in 2011 and it relies on third-party assertions, mocking, and spying tools(Spies are objects that keep track of their interaction with other objects or pieces of code. Very extensible and has a lot of plugins, extensions, and libraries designed to run on, Easy-to-user Asynchronous Testing.

  • Test Environment - Mocha
  • Assertion Library - ChaiJS (Expect, Should and Assert)
  • Spy, Stub & Mock (Assertion) - SinonJS

spies - It offers information about actual Functions, without affecting their behavior
stubs - It completely replaces the actual function (Ajax, DB)
mocks - It helps to replace whole objects by combining both spies and stubs

Chai:

Typically Mocha pairs with Chai...Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.

Jest:

Jest is an open source testing framework developed by Facebook. Built into the popular create-react-app package, is faster and smoother to write idiomatic JavaScript tests. ... Mocha provides developers with a base test framework, with options such as assertion, mocking, and spy libraries.

Now it's time to see why JEST is better than anyone... 

Typically Mocha pairs with Chai.. however, when using Jest you will not need to rely explicitly on a third-party assertion library. Let's see some live examples so we can see how the underlying API's differ between the two.
















Ref: https://blog.logrocket.com/the-best-unit-testing-frameworks-for-node-js/


Hope this helps.. 

Arun Manglick

No comments:

Post a Comment