jest

Partial Matching in Jest

Partial Matching in Jest

  • October 25, 2023

Jest has the ability to check for partial matches on arrays and objects. Let us see how to do partial matching in Jest. expect has powerful matcher methods for partial matching, and they can also be combined with the tohavebeencalledwith method. Matching objects partially using expect.objectContaining When trying only to...

How to unit-test a private (non-exported) function in JavaScript

How to unit-test a private (non-exported) function in JavaScript

  • November 19, 2020

When writing unit-tests for JavaScript modules, we often encounter a dilemma wherein the module has some private functions that have not been exported. Testing a function that has been exported is easy since it can be imported in the unit testing framework, and the functionality can be tested. But how...