MCPcopy
hub / github.com/vitest-dev/vitest / def

Function def

packages/expect/src/jest-expect.ts:42–62  ·  view source on GitHub ↗
(
    name: keyof Assertion | (keyof Assertion)[],
    fn: (this: Chai.AssertionStatic & Assertion, ...args: any[]) => any,
  )

Source from the content-addressed store, hash-verified

40 const customTesters = getCustomEqualityTesters()
41
42 function def(
43 name: keyof Assertion | (keyof Assertion)[],
44 fn: (this: Chai.AssertionStatic & Assertion, ...args: any[]) => any,
45 ) {
46 const addMethod = (n: keyof Assertion) => {
47 const softWrapper = wrapAssertion(utils, n, fn)
48 utils.addMethod(chai.Assertion.prototype, n, softWrapper)
49 utils.addMethod(
50 (globalThis as any)[JEST_MATCHERS_OBJECT].matchers,
51 n,
52 softWrapper,
53 )
54 }
55
56 if (Array.isArray(name)) {
57 name.forEach(n => addMethod(n))
58 }
59 else {
60 addMethod(name)
61 }
62 }
63
64 (['throw', 'throws', 'Throw'] as const).forEach((m) => {
65 utils.overwriteMethod(chai.Assertion.prototype, m, (_super: any) => {

Callers 1

JestChaiExpectFunction · 0.85

Calls 1

addMethodFunction · 0.85

Tested by

no test coverage detected