0

I am passing the data in .mockResolvedValue() method and it is working as expected by providing the correct result. Example :

    getDataFromApex({accountId : this.accountId})
    .then((result) => {
          this.someData = result;
          this.getAnotherDataFromApex();
     })
     .catch((error) => {
                this.error = error;
                this.books = undefined;
     }); 
 

    getAnotherDataFromApex() {
     getNestedImperativeData({someData : this.someData})
    .then((result) => {
          console.log('getNestedImperativeData result :',result);  //Not getting called from jest
          this.someData = result;
          this.getAnotherDataFromApex();
     })
     .catch((error) => {
                this.error = error;
                this.books = undefined;
     });
}

Have created Jest.mock() for both the calls with valid data

3
  • Could you share the code of your tests as well?
    – POZ
    Jan 12 at 19:05
  • Hey Philippe @POZ Thanks for replying back! but got the issue , I was passing the dummy data in the form of object but the method was expecting it in string and doing JSON.parse() to convert the data to object. Jan 13 at 7:43
  • Cool, no problem. Can you close the question then?
    – POZ
    Jan 14 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.