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

Do you see value in our efforts?

Devtools Tech is a free platform for Frontend Engineers. It takes a lot of time, effort, and finanical resources to keep the platform running. If you see any value in our work and would like to support us then you can do using the following options.


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...