@samitouri / QOS-React-2 / commits / 73ff8b9094

Run ReactElementJSX-test against bundles (#18301)

* Run ReactElementJSX-test against bundles * Try the new thing

Dan Abramov committed Mar 13, 2020 at 12:07 UTC 73ff8b9094f9061c097d7f58fb4b02a90fa6f107
1 file changed +22 -23
packages/react/src/__tests__/ReactElementJSX-test.js renamed
+22 -23
@@ -13,8 +13,6 @@ let React;
13 let ReactDOM;
14 let ReactTestUtils;
15
16 -let ReactFeatureFlags = require('shared/ReactFeatureFlags');
17 -
16 // NOTE: We're explicitly not using JSX here. This is intended to test
17 // a new React.jsx api which does not have a JSX transformer yet.
18 // A lot of these tests are pulled from ReactElement-test because
@@ -30,9 +28,6 @@ describe('ReactElement.jsx', () => {
28 originalSymbol = global.Symbol;
29 global.Symbol = undefined;
30
33 - ReactFeatureFlags = require('shared/ReactFeatureFlags');
34 - ReactFeatureFlags.warnAboutSpreadingKeyToJSX = true;
35 -
31 React = require('react');
32 ReactDOM = require('react-dom');
33 ReactTestUtils = require('react-dom/test-utils');
@@ -356,26 +351,30 @@ describe('ReactElement.jsx', () => {
351 );
352 });
353
359 - it('should warn when keys are passed as part of props', () => {
360 - const container = document.createElement('div');
361 - class Child extends React.Component {
362 - render() {
363 - return React.jsx('div', {});
354 + if (require('shared/ReactFeatureFlags').warnAboutSpreadingKeyToJSX) {
355 + it('should warn when keys are passed as part of props', () => {
356 + const container = document.createElement('div');
357 + class Child extends React.Component {
358 + render() {
359 + return React.jsx('div', {});
360 + }
361 }
365 - }
366 - class Parent extends React.Component {
367 - render() {
368 - return React.jsx('div', {
369 - children: [React.jsx(Child, {key: '0'})],
370 - });
362 + class Parent extends React.Component {
363 + render() {
364 + return React.jsx('div', {
365 + children: [React.jsx(Child, {key: '0'})],
366 + });
367 + }
368 }
372 - }
373 - expect(() => ReactDOM.render(React.jsx(Parent, {}), container)).toErrorDev(
374 - 'Warning: React.jsx: Spreading a key to JSX is a deprecated pattern. ' +
375 - 'Explicitly pass a key after spreading props in your JSX call. ' +
376 - 'E.g. <Child {...props} key={key} />',
377 - );
378 - });
369 + expect(() =>
370 + ReactDOM.render(React.jsx(Parent, {}), container),
371 + ).toErrorDev(
372 + 'Warning: React.jsx: Spreading a key to JSX is a deprecated pattern. ' +
373 + 'Explicitly pass a key after spreading props in your JSX call. ' +
374 + 'E.g. <Child {...props} key={key} />',
375 + );
376 + });
377 + }
378
379 it('should not warn when unkeyed children are passed to jsxs', () => {
380 const container = document.createElement('div');