Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Undistraction/f3388438d41c0f449316abb625b4c932 to your computer and use it in GitHub Desktop.
Save Undistraction/f3388438d41c0f449316abb625b4c932 to your computer and use it in GitHub Desktop.
jest mock
let data;
let errorMessage;
const analyseImageWithVibrant = jest.fn(
() => new Promise((resolve, reject) => {
if (data) {
resolve(data);
} else {
reject(errorMessage);
}
}),
);
export default analyseImageWithVibrant;
// eslint-disable-next-line no-underscore-dangle
export const __setData = (d, message) => {
data = d;
errorMessage = message;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment