Use match functions for mocks
masterBoth mockClient and mockRequest support match functions to validate request properties.
mockClientaccepts match functions forbodyandparams.mockRequestaccepts match functions forbodyandurl.
Built-in match functions from mappersmith/test (m):
m.stringMatching(regexp): Accepts a regular expression.m.stringContaining(string): Accepts a substring.m.anything(): Accepts any value.m.uuid4(): Accepts a UUID v4.
You can also provide a custom function that returns a boolean:
import { m } from 'mappersmith/test'
// Custom function match
mockClient(client).with({
body: (body) => body === 'something'
})import { m } from 'mappersmith/test'
m.stringMatching(/something/)
m.stringContaining('some-string')
m.anything()
m.uuid4()