Implement your own Testing Library | Frontend Problem Solving | JavaScript Interview Question
@Yomesh Gupta

In this question, you need to replicate the popular testing library jest functionality. You must implement the utility expect provided by the jest library.

// Syntax

customExpect(3).toBe(3); // no error | Do not return anything
customExpect(2).toBe(3); // should throw an error

customExpect(2).not.toBe(3); // no error | Do not return anything
customExpect(2).not.toBe(2); // should throw an error

Your customExpect function should support the functionality of toBe and not.toBe.

P.S. We have provided a stopwatch timer at the top. Start the timer when you are about to try this question and try to finish within 15-20 mins.


Once you are successfully done with this then try to implement more methods from jest. Find full list here:

Loading IDE...