Skip to content

Instantly share code, notes, and snippets.

@DanSnow
Created November 16, 2016 05:33
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 DanSnow/5deacc55e4864b70d772eaf6e81ea58b to your computer and use it in GitHub Desktop.
Save DanSnow/5deacc55e4864b70d772eaf6e81ea58b to your computer and use it in GitHub Desktop.
Wrapper for jasmine-immutable-matchers to make it work on jest > 17
import * as jasmineImmutable from 'jasmine-immutable-matchers'
import mapValues from 'lodash/mapValues'
const jestImmutable = mapValues(jasmineImmutable, (matcherFactory) => {
const matcher = matcherFactory()
return function () {
const { isNot } = this
const { pass, message } = matcher[isNot ? 'negativeCompare' : 'compare'](...arguments)
return {
pass: Boolean(pass),
message
}
}
})
expect.extend(jestImmutable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment