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
packages/internal-test-utils
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: packages/internal-test-utils/__tests__/ReactInternalTestUtils-test.js +22Lines changed: 22 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2129,6 +2129,28 @@ describe('ReactInternalTestUtils console assertions', () => { |
2129 | 2129 | `); |
2130 | 2130 | }); |
2131 | 2131 |
|
| 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 | + |
2132 | 2154 | describe('global withoutStack', () => { |
2133 | 2155 | // @gate __DEV__ |
2134 | 2156 | it('passes if errors without stack explicitly opt out', () => { |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/internal-test-utils/consoleMock.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -386,7 +386,7 @@ export function createLogAssertion( |
386 | 386 | expectedWithoutStack = expectedMessageOrArray[1].withoutStack; |
387 | 387 | } else if (typeof expectedMessageOrArray === 'string') { |
388 | 388 | // Should be in the form assert(['log']) or assert(['log'], {withoutStack: true}) |
389 | | - expectedMessage = replaceComponentStack(expectedMessageOrArray[0]); |
| 389 | + expectedMessage = replaceComponentStack(expectedMessageOrArray); |
390 | 390 | if (consoleMethod === 'log') { |
391 | 391 | expectedWithoutStack = true; |
392 | 392 | } else { |
|