Skip to content

Commit

Permalink
Return UNDEFINED for undefined type in ReactElement plugin (#4360)
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrottimark authored and cpojer committed Aug 25, 2017
1 parent 96ba36f commit 1938409
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/pretty-format/src/__tests__/react.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ test('supports Unknown element', () => {
// Suppress React.createElement(undefined) console error
const consoleError = console.error;
(console: Object).error = jest.fn();
expect(formatElement(React.createElement(undefined))).toEqual('<Unknown />');
expect(formatElement(React.createElement(undefined))).toEqual(
'<UNDEFINED />',
);
(console: Object).error = consoleError;
});

Expand Down
2 changes: 1 addition & 1 deletion packages/pretty-format/src/plugins/react_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const getType = element => {
if (typeof element.type === 'function') {
return element.type.displayName || element.type.name || 'Unknown';
}
return 'Unknown';
return 'UNDEFINED';
};

export const serialize = (
Expand Down

0 comments on commit 1938409

Please sign in to comment.