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

4
  • Could you share the code of your tests as well?
    – POZ
    Jan 12, 2022 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, 2022 at 7:43
  • Cool, no problem. Can you close the question then?
    – POZ
    Jan 14, 2022 at 14:02
  • Yes sure thank you :) Apr 28, 2022 at 10:03

1 Answer 1

1

Got the issue , I was passing the dummy data in the form of object but the method was expecting it in a string and doing JSON.parse() to convert the data to object. Worked after the right dummy data was sent.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .