Skip to content

Commit

Permalink
When a generated test case fails, log its input
Browse files Browse the repository at this point in the history
  • Loading branch information
acdlite committed Nov 8, 2018
1 parent 709d142 commit b6629ca
Showing 1 changed file with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ let ReactTestRenderer;
let ReactFeatureFlags;
let originalConsoleError;

// const prettyFormatPkg = require('pretty-format');
// function prettyFormat(thing) {
// prettyFormatPkg(thing, {
// plugins: [
// prettyFormatPkg.plugins.ReactElement,
// prettyFormatPkg.plugins.ReactTestComponent,
// ],
// });
// }
const prettyFormatPkg = require('pretty-format');

function prettyFormat(thing) {
return prettyFormatPkg(thing, {
plugins: [
prettyFormatPkg.plugins.ReactElement,
prettyFormatPkg.plugins.ReactTestComponent,
],
});
}

describe('ReactSuspenseFuzz', () => {
beforeEach(() => {
Expand Down Expand Up @@ -340,7 +341,17 @@ describe('ReactSuspenseFuzz', () => {

for (let i = 0; i < NUMBER_OF_TEST_CASES; i++) {
const randomTestCase = generateTestCase(ELEMENTS_PER_CASE);
testResolvedOutput(randomTestCase);
try {
testResolvedOutput(randomTestCase);
} catch (e) {
console.log(`
Failed fuzzy test case:
${prettyFormat(randomTestCase)}
`);

throw e;
}
}
});
});

0 comments on commit b6629ca

Please sign in to comment.