Skip to content

Commit d9666f1

Browse files
committed
When a generated test case fails, log its input
1 parent 4aff56c commit d9666f1

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

packages/react-reconciler/src/__tests__/ReactSuspenseFuzz-test.internal.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ let ReactTestRenderer;
33
let ReactFeatureFlags;
44
let originalConsoleError;
55

6-
// const prettyFormatPkg = require('pretty-format');
7-
// function prettyFormat(thing) {
8-
// prettyFormatPkg(thing, {
9-
// plugins: [
10-
// prettyFormatPkg.plugins.ReactElement,
11-
// prettyFormatPkg.plugins.ReactTestComponent,
12-
// ],
13-
// });
14-
// }
6+
const prettyFormatPkg = require('pretty-format');
7+
8+
function prettyFormat(thing) {
9+
return prettyFormatPkg(thing, {
10+
plugins: [
11+
prettyFormatPkg.plugins.ReactElement,
12+
prettyFormatPkg.plugins.ReactTestComponent,
13+
],
14+
});
15+
}
1516

1617
describe('ReactSuspenseFuzz', () => {
1718
beforeEach(() => {
@@ -311,7 +312,17 @@ describe('ReactSuspenseFuzz', () => {
311312

312313
for (let i = 0; i < NUMBER_OF_TEST_CASES; i++) {
313314
const randomTestCase = generateTestCase(ELEMENTS_PER_CASE);
314-
testResolvedOutput(randomTestCase);
315+
try {
316+
testResolvedOutput(randomTestCase);
317+
} catch (e) {
318+
console.log(`
319+
Failed fuzzy test case:
320+
321+
${prettyFormat(randomTestCase)}
322+
`);
323+
324+
throw e;
325+
}
315326
}
316327
});
317328
});

0 commit comments

Comments
 (0)