Skip to content

Commit

Permalink
Add new workaround for React.createElement(undefined)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Aug 26, 2017
1 parent 13c8f0a commit 67d5dcf
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/pretty-format/src/__tests__/react.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {OptionsReceived} from 'types/PrettyFormat';
const React = require('react');
const renderer = require('react-test-renderer');

const elementSymbol = Symbol.for('react.element'); // ADD preceding the following line:
const testSymbol = Symbol.for('react.test.json');

const prettyFormat = require('../');
Expand Down Expand Up @@ -301,14 +302,10 @@ test('supports a single element with custom React elements with a child', () =>
);
});

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(
test('supports undefined element type', () => {
expect(formatElement({$$typeof: elementSymbol, props: {}})).toEqual(
'<UNDEFINED />',
);
(console: Object).error = consoleError;
});

test('supports a single element with React elements with a child', () => {
Expand Down

0 comments on commit 67d5dcf

Please sign in to comment.