Skip to main content
Testing & QA Code Completion Hard +35 XP

Custom Matcher

Complete to extend Jest with a custom matcher.

Testing & QAFill in the blank
expect.___({ toBePositive(received) { return { pass: received > 0, message: () => 'Expected positive' }; } });

Type the missing code

Show answer and explanation

Answer: extend

expect.extend() adds custom matchers to Jest. Each matcher returns { pass, message } for success/failure reporting.

Hint: Which expect method adds custom matchers?

What this challenge tests

Code Completion in Testing & QA: jest, custom-matchers.

Related challenges