Skip to content

Instantly share code, notes, and snippets.

@py-in-the-sky
Last active January 21, 2016 23:51
Show Gist options
  • Save py-in-the-sky/d502ee71a4bfc5311f5c to your computer and use it in GitHub Desktop.
Save py-in-the-sky/d502ee71a4bfc5311f5c to your computer and use it in GitHub Desktop.
Mock a no-op promise.
/*
Needed to mock a promise for a test just so that chaining `then`s
and `catch`es wouldn't throw an error. The actual execution of
those `then`s and `catches` could be no-ops since the test wasn't
concerned with their functionality.
The mocked promise (`returnMockThenable()`) was returned from a mock
`fetch` call.
*/
const returnMockThenable = () => ({
then: returnMockThenable,
catch: returnMockThenable,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment