Skip to content
Advertisement

I am trying to test using jest for a function that calls back a success message to be displayed once a task is added to array but its erroring out

This is the code I have to so far. I need help with my test function using jest. Visual studio points error to function addTask(“task 3) in the test function. The rest of the code executes fine i.e I am able to display a success message after adding task to the array. The test should pass this requirement of displaying success message only after adding the task to the array.

JavaScript

Advertisement

Answer

I had converted the above problem into using a promise. I was able to produce the test case with simpler understanding upon using and returning the value of promise rather than callbacks. I am still a noob but this is what has been working for me so far.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement