Skip to content

Commit

Permalink
Fix assertConsoleErrorDev on message mismatch with withoutStack: true
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed May 21, 2024
1 parent 4419f76 commit 6a01abd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2427,7 +2427,17 @@ describe('ReactInternalTestUtils console assertions', () => {
],
]);
});
expect(message).toMatchInlineSnapshot(`"message.replace is not a function"`);
expect(message).toMatchInlineSnapshot(`
"assertConsoleErrorDev(expected)
Unexpected error(s) recorded.
- Expected errors
+ Received errors
- Hello
+ Bye <component stack>"
`);
});
});

Expand Down
7 changes: 6 additions & 1 deletion packages/internal-test-utils/consoleMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,12 @@ export function createLogAssertion(
function printDiff() {
return `${diff(
expectedMessages
.map(message => message.replace('\n', ' '))
.map(messageOrTuple => {
const message = Array.isArray(messageOrTuple)
? messageOrTuple[0]
: messageOrTuple;
return message.replace('\n', ' ');
})
.join('\n'),
receivedLogs.map(message => message.replace('\n', ' ')).join('\n'),
{
Expand Down

0 comments on commit 6a01abd

Please sign in to comment.