You need Login/Signup to run/submit the code.
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(actual).toBe(expected);
customExpect(actual).not.toBe(expected);
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.
Bonus
Once you are successfully done with this then try to implement more methods from jest
. Find full list here: https://jestjs.io/docs/expect