[Vuejs]-How to unittest a vuejs component update with methods using promise

0👍

Jest docs say

it expects the return value to be a Promise that is going to be
resolved.

You have a promise that is going to be rejected, so you need a Promise that resolves when your promise is rejected.

  isRejected(rejectingPromise, someExpects) {
    return new Promise((resolve) => {
      rejectingPromise.then(
        () => null,  // if it resolves, fail
        (err) => {   // if it rejects, resolve
          // Maybe do someExpects() here
          resolve();
        }
    });
  }

Leave a comment