How to use the jest-snapshot.toMatchSnapshot.apply function in jest-snapshot

To help you get started, we’ve selected a few jest-snapshot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kentcdodds / jest-glamor-react / src / matcher.js View on Github external
toMatchSnapshotWithGlamor(...args) {
    const result = toMatchSnapshot.apply(this, args)
    let message

    if (!result.pass) {
      message = diff(result.expected, result.actual, {
        aAnnotation: 'Snapshot',
        bAnnotation: 'Received',
      })
      message = stripAnsi(message)
      message = colorize(message)
    }

    return {pass: result.pass, message}
  },
}