GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — console test utils fix: match entire string, not just first letter (#… · react/react@f82051d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/internal-test-utils
    • __tests__
      • ReactInternalTestUtils-test.js
    • consoleMock.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/internal-test-utils/__tests__/ReactInternalTestUtils-test.js‎

Copy file name to clipboardExpand all lines: packages/internal-test-utils/__tests__/ReactInternalTestUtils-test.js
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,6 +2129,28 @@ describe('ReactInternalTestUtils console assertions', () => {
21292129
`);
21302130
});
21312131

2132+
// @gate __DEV__
2133+
it('regression: checks entire string, not just the first letter', async () => {
2134+
const message = expectToThrowFailure(() => {
2135+
console.error('Message that happens to contain a "T"\n in div');
2136+
2137+
assertConsoleErrorDev([
2138+
'This is a completely different message that happens to start with "T"',
2139+
]);
2140+
});
2141+
expect(message).toMatchInlineSnapshot(`
2142+
"assertConsoleErrorDev(expected)
2143+
2144+
Unexpected error(s) recorded.
2145+
2146+
- Expected errors
2147+
+ Received errors
2148+
2149+
- This is a complete different message that happens to start with "T"
2150+
+ Message that happens to contain a "T" <component stack>"
2151+
`);
2152+
});
2153+
21322154
describe('global withoutStack', () => {
21332155
// @gate __DEV__
21342156
it('passes if errors without stack explicitly opt out', () => {
Collapse file

‎packages/internal-test-utils/consoleMock.js‎

Copy file name to clipboardExpand all lines: packages/internal-test-utils/consoleMock.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ export function createLogAssertion(
386386
expectedWithoutStack = expectedMessageOrArray[1].withoutStack;
387387
} else if (typeof expectedMessageOrArray === 'string') {
388388
// Should be in the form assert(['log']) or assert(['log'], {withoutStack: true})
389-
expectedMessage = replaceComponentStack(expectedMessageOrArray[0]);
389+
expectedMessage = replaceComponentStack(expectedMessageOrArray);
390390
if (consoleMethod === 'log') {
391391
expectedWithoutStack = true;
392392
} else {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.