Skip to content
GitHub

MockTypeOptions

interface in meocord/testing Since 4.3.0

interface MockTypeOptions

Switches on checks of the values a test gives a mock and reads back from it, for the whole project, by declaration merging.

Declared empty. With typedValues: true merged in, the mock API of every MockedFunction is typed from the function it mocks: mock.calls, mock.lastCall, mock.results and mock.settledResults hold its arguments and results, mockReturnValue and mockImplementation take only values and functions it could return or be, and mockResolvedValue takes what it resolves to, or undefined, which a mock's answers resolve to by default. An overloaded function's values are a union over its signatures, up to four of them; a fifth is left out. Without it, those values are any. It checks types only: useStrictMocks() is what changes how a mock behaves. The next major version (5.0) types the values by default, and typedValues: false opts out (meocord#561).

Examples

TypeScript
// src/types/meocord-testing.d.ts
import 'meocord/testing'

declare module 'meocord/testing' {
  interface MockTypeOptions {
    typedValues: true
  }
}

See also