Skip to content

Instantly share code, notes, and snippets.

@sam-artuso
Created February 14, 2017 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sam-artuso/281e4273cf582f764ebd156f194dc559 to your computer and use it in GitHub Desktop.
Save sam-artuso/281e4273cf582f764ebd156f194dc559 to your computer and use it in GitHub Desktop.
How to unit test a promise deliberately designed to side-effect?
// demo.js
function f() {
return Promise.resolve(true)
}
function g() {
Promise.resolve(true)
}
module.exports = { f, g }
// demo.test.js
const demo = require('./demo')
describe('f()', () => {
it('should resolve to true', () => {
return demo.f().then(result => {
expect(result).toBe(true)
})
})
})
describe('g()', () => {
it.skip('should resolve to true', () => {
// ???
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment