From e3140f54259999be19bfdadd67b5a36b8e709cdc Mon Sep 17 00:00:00 2001 From: Michael Rienstra Date: Thu, 9 Sep 2021 08:45:11 -0700 Subject: [PATCH] chore(expect): add 2 print utils to main expect export (expect.print) (print utils from src/print) --- packages/expect/src/index.ts | 9 +++++++++ packages/expect/src/types.ts | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/packages/expect/src/index.ts b/packages/expect/src/index.ts index 74a7c6f841c1..6f514edf2d20 100644 --- a/packages/expect/src/index.ts +++ b/packages/expect/src/index.ts @@ -31,6 +31,10 @@ import { setState, } from './jestMatchersObject'; import matchers from './matchers'; +import { + printReceivedStringContainExpectedResult, + printReceivedStringContainExpectedSubstring, +} from './print'; import spyMatchers from './spyMatchers'; import toThrowMatchers, { createMatcher as createThrowMatcher, @@ -358,6 +362,11 @@ expect.extend = (matchers: MatchersObject): void => setMatchers(matchers, false, expect); expect.matchers = matchers; +expect.print = { + printReceivedStringContainExpectedResult, + printReceivedStringContainExpectedSubstring, +}; + expect.anything = anything; expect.any = any; diff --git a/packages/expect/src/types.ts b/packages/expect/src/types.ts index e0113ef67d5e..9e920e745d4a 100644 --- a/packages/expect/src/types.ts +++ b/packages/expect/src/types.ts @@ -84,6 +84,17 @@ export type Expect = { [id: string]: AsymmetricMatcher; not: {[id: string]: AsymmetricMatcher}; matchers: MatchersObject; + print: { + printReceivedStringContainExpectedResult( + received: string, + result: RegExpExecArray | null, + ): string; + printReceivedStringContainExpectedSubstring( + received: string, + start: number, + length: number, + ): string; + }; }; interface Constructable {