function mock ({ bump, changelog, tags }) {
  if (bump === undefined) throw new Error('bump must be defined for mock()')
  mockery.enable({ warnOnUnregistered: false, useCleanCache: true })

  mockery.registerMock('conventional-recommended-bump', function (opt, cb) {
    if (typeof bump === 'function') bump(opt, cb)
    else if (bump instanceof Error) cb(bump)
    else cb(null, { releaseType: bump })
  })

  if (!Array.isArray(changelog)) changelog = [changelog]
  mockery.registerMock('conventional-changelog', (opt) => new Readable({
    read (_size) {
      const next = changelog.shift()
      if (next instanceof Error) {
        this.destroy(next)
      } else if (typeof next === 'function') {
        this.push(next(opt))
      } else {
        this.push(next ? Buffer.from(next, 'utf8') : null)
      }
    }
  }))

  mockery.registerMock('git-semver-tags', function (_, cb) {
    if (tags instanceof Error) cb(tags)
    else cb(null, tags || [])
  })

  stdMocks.use()
  return () => stdMocks.flush()
}
Mock external conventional-changelog modules

bump: 'major' | 'minor' | 'patch' | Error | (opt, cb) => { cb(err) | cb(null, { releaseType }) }
changelog?: string | Error | Array<string | Error | (opt) => string | null>
tags?: string[] | Error