Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d9d9ca6

Browse filesBrowse files
committed
feat: pass options and replace colors in extractExpectedAssertionsErrors.ts
1 parent 5dc8dd2 commit d9d9ca6
Copy full SHA for d9d9ca6

File tree

Expand file treeCollapse file tree

1 file changed

+13
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-5
lines changed

‎packages/expect/src/extractExpectedAssertionsErrors.ts

Copy file name to clipboardExpand all lines: packages/expect/src/extractExpectedAssertionsErrors.ts
+13-5Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,28 @@ const extractExpectedAssertionsErrors: Expect['extractExpectedAssertionsErrors']
3535
expectedAssertionsNumberError,
3636
isExpectingAssertions,
3737
isExpectingAssertionsError,
38+
matcherHintOptions,
3839
} = getState();
3940

41+
const expectedColor = matcherHintOptions?.expectedColor ?? EXPECTED_COLOR;
42+
const receivedColor = matcherHintOptions?.receivedColor ?? RECEIVED_COLOR;
43+
4044
resetAssertionsLocalState();
4145

4246
if (
4347
typeof expectedAssertionsNumber === 'number' &&
4448
assertionCalls !== expectedAssertionsNumber
4549
) {
46-
const numOfAssertionsExpected = EXPECTED_COLOR(
50+
const numOfAssertionsExpected = expectedColor(
4751
pluralize('assertion', expectedAssertionsNumber),
4852
);
4953

5054
expectedAssertionsNumberError!.message =
5155
`${matcherHint('.assertions', '', expectedAssertionsNumber.toString(), {
56+
...matcherHintOptions,
5257
isDirectExpectCall: true,
5358
})}\n\n` +
54-
`Expected ${numOfAssertionsExpected} to be called but received ${RECEIVED_COLOR(
59+
`Expected ${numOfAssertionsExpected} to be called but received ${receivedColor(
5560
pluralize('assertion call', assertionCalls || 0),
5661
)}.`;
5762

@@ -62,14 +67,17 @@ const extractExpectedAssertionsErrors: Expect['extractExpectedAssertionsErrors']
6267
});
6368
}
6469
if (isExpectingAssertions && assertionCalls === 0) {
65-
const expected = EXPECTED_COLOR('at least one assertion');
66-
const received = RECEIVED_COLOR('received none');
70+
const expected = expectedColor('at least one assertion');
71+
const received = receivedColor('received none');
6772

6873
isExpectingAssertionsError!.message = `${matcherHint(
6974
'.hasAssertions',
7075
'',
7176
'',
72-
{isDirectExpectCall: true},
77+
{
78+
...matcherHintOptions,
79+
isDirectExpectCall: true,
80+
},
7381
)}\n\nExpected ${expected} to be called but ${received}.`;
7482

7583
result.push({

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.