From b02a9071b46dd8def7599c6ee37787cd339054f7 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 20 Oct 2017 19:06:48 +0100 Subject: [PATCH] Fix all tests It seems we can't use relative requires in tests anymore. Otherwise Jest becomes confused between real file and symlink. https://github.com/facebook/jest/issues/3830 This seems bad... Except that we already *don't* want people to create tests that import individual source files. All existing cases of us doing so are actually TODOs waiting to be fixed. So perhaps this requirement isn't too bad because it makes bad code looks bad. Of course, if we go with this, we'll have to lint against relative requires in tests. It also makes moving things more painful. --- packages/events/__tests__/EventPluginRegistry-test.js | 2 +- packages/events/__tests__/ResponderEventPlugin-test.js | 2 +- packages/events/__tests__/accumulateInto-test.js | 2 +- .../react-cs-renderer/src/__tests__/ReactNativeCS-test.js | 2 +- .../src/__tests__/ReactBrowserEventEmitter-test.js | 6 +++--- .../react-dom/src/__tests__/ReactDOMComponent-test.js | 2 +- .../react-dom/src/__tests__/ReactDOMComponentTree-test.js | 2 +- .../react-dom/src/__tests__/ReactDOMEventListener-test.js | 4 ++-- .../react-dom/src/__tests__/ReactDOMSelection-test.js | 2 +- packages/react-dom/src/__tests__/ReactMount-test.js | 2 +- .../react-dom/src/__tests__/ReactServerRendering-test.js | 2 +- .../react-dom/src/__tests__/ReactTreeTraversal-test.js | 2 +- .../src/__tests__/escapeTextContentForBrowser-test.js | 2 +- .../react-dom/src/__tests__/inputValueTracking-test.js | 2 +- .../src/__tests__/quoteAttributeValueForBrowser-test.js | 2 +- .../react-dom/src/__tests__/validateDOMNesting-test.js | 2 +- .../client/__tests__/getNodeForCharacterOffset-test.js | 2 +- .../react-dom/src/client/__tests__/setInnerHTML-test.js | 4 ++-- .../src/events/__tests__/BeforeInputEventPlugin-test.js | 8 ++++---- .../src/events/__tests__/ChangeEventPlugin-test.js | 4 ++-- .../src/events/__tests__/EnterLeaveEventPlugin-test.js | 4 ++-- .../src/events/__tests__/FallbackCompositionState-test.js | 2 +- .../src/events/__tests__/SelectEventPlugin-test.js | 4 ++-- .../src/events/__tests__/SyntheticClipboardEvent-test.js | 4 ++-- .../react-dom/src/events/__tests__/SyntheticEvent-test.js | 2 +- .../src/events/__tests__/SyntheticKeyboardEvent-test.js | 8 ++++---- .../src/events/__tests__/SyntheticWheelEvent-test.js | 4 ++-- .../src/events/__tests__/getEventCharCode-test.js | 2 +- .../react-dom/src/events/__tests__/getEventKey-test.js | 2 +- packages/react-native-renderer/src/ReactNativeRenderer.js | 2 +- .../src/__tests__/ReactNativeAttributePayload-test.js | 4 ++-- .../src/__tests__/ReactNativeEvents-test.js | 4 ++-- .../src/__tests__/ReactNativeMount-test.js | 2 +- .../src/__tests__/createReactNativeComponentClass-test.js | 2 +- .../src/__tests__/ReactIncrementalPerf-test.js | 4 ++-- .../src/__tests__/ReactPersistent-test.js | 2 +- packages/shared/__tests__/ReactErrorUtils-test.js | 8 ++++---- packages/shared/__tests__/reactProdInvariant-test.js | 2 +- 38 files changed, 59 insertions(+), 59 deletions(-) diff --git a/packages/events/__tests__/EventPluginRegistry-test.js b/packages/events/__tests__/EventPluginRegistry-test.js index 7fe430719a96c..d0907ce810a10 100644 --- a/packages/events/__tests__/EventPluginRegistry-test.js +++ b/packages/events/__tests__/EventPluginRegistry-test.js @@ -16,7 +16,7 @@ describe('EventPluginRegistry', () => { beforeEach(() => { jest.resetModuleRegistry(); // TODO: can we express this test with only public API? - EventPluginRegistry = require('../EventPluginRegistry'); + EventPluginRegistry = require('shared/event/EventPluginRegistry'); createPlugin = function(properties) { return Object.assign({extractEvents: function() {}}, properties); diff --git a/packages/events/__tests__/ResponderEventPlugin-test.js b/packages/events/__tests__/ResponderEventPlugin-test.js index ff542b066656e..ea3d7325e6d58 100644 --- a/packages/events/__tests__/ResponderEventPlugin-test.js +++ b/packages/events/__tests__/ResponderEventPlugin-test.js @@ -9,7 +9,7 @@ 'use strict'; -var {HostComponent} = require('../../../ReactTypeOfWork'); +var {HostComponent} = require('shared/ReactTypeOfWork'); var EventPluginHub; var ResponderEventPlugin; diff --git a/packages/events/__tests__/accumulateInto-test.js b/packages/events/__tests__/accumulateInto-test.js index addb6c0642563..a3b70118b7950 100644 --- a/packages/events/__tests__/accumulateInto-test.js +++ b/packages/events/__tests__/accumulateInto-test.js @@ -13,7 +13,7 @@ var accumulateInto; describe('accumulateInto', () => { beforeEach(() => { - accumulateInto = require('../accumulateInto'); + accumulateInto = require('shared/event/accumulateInto'); }); it('throws if the second item is null', () => { diff --git a/packages/react-cs-renderer/src/__tests__/ReactNativeCS-test.js b/packages/react-cs-renderer/src/__tests__/ReactNativeCS-test.js index 98817ad22a635..1ab109be10bc0 100644 --- a/packages/react-cs-renderer/src/__tests__/ReactNativeCS-test.js +++ b/packages/react-cs-renderer/src/__tests__/ReactNativeCS-test.js @@ -12,7 +12,7 @@ var React; var ReactNativeCS; -jest.mock('shared/ReactFeatureFlags', () => require('shared/ReactNativeCSFeatureFlags')); +jest.mock('shared/ReactFeatureFlags', () => require('react-cs-renderer/src/ReactNativeCSFeatureFlags')); describe('ReactNativeCS', () => { beforeEach(() => { diff --git a/packages/react-dom/src/__tests__/ReactBrowserEventEmitter-test.js b/packages/react-dom/src/__tests__/ReactBrowserEventEmitter-test.js index 0486a2a48ca7d..1e04f9afa0e20 100644 --- a/packages/react-dom/src/__tests__/ReactBrowserEventEmitter-test.js +++ b/packages/react-dom/src/__tests__/ReactBrowserEventEmitter-test.js @@ -63,10 +63,10 @@ describe('ReactBrowserEventEmitter', () => { EventPluginRegistry = require('shared/event/EventPluginRegistry'); React = require('react'); ReactDOM = require('react-dom'); - ReactDOMComponentTree = require('../client/ReactDOMComponentTree'); - ReactBrowserEventEmitter = require('../client/event/ReactBrowserEventEmitter'); + ReactDOMComponentTree = require('react-dom/src/client/ReactDOMComponentTree'); + ReactBrowserEventEmitter = require('react-dom/src/client/event/ReactBrowserEventEmitter'); ReactTestUtils = require('react-dom/test-utils'); - TapEventPlugin = require('../client/event/plugins/TapEventPlugin'); + TapEventPlugin = require('react-dom/src/client/event/plugins/TapEventPlugin'); var container = document.createElement('div'); diff --git a/packages/react-dom/src/__tests__/ReactDOMComponent-test.js b/packages/react-dom/src/__tests__/ReactDOMComponent-test.js index b0f205a148506..c16c4a8fdd3ae 100644 --- a/packages/react-dom/src/__tests__/ReactDOMComponent-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMComponent-test.js @@ -27,7 +27,7 @@ describe('ReactDOMComponent', () => { ReactDOMServer = require('react-dom/server'); ReactTestUtils = require('react-dom/test-utils'); // TODO: can we express this test with only public API? - inputValueTracking = require('../client/inputValueTracking'); + inputValueTracking = require('react-dom/src/client/inputValueTracking'); }); describe('updateDOM', () => { diff --git a/packages/react-dom/src/__tests__/ReactDOMComponentTree-test.js b/packages/react-dom/src/__tests__/ReactDOMComponentTree-test.js index 366cedd08d3d4..1ff250f2569ec 100644 --- a/packages/react-dom/src/__tests__/ReactDOMComponentTree-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMComponentTree-test.js @@ -34,7 +34,7 @@ describe('ReactDOMComponentTree', () => { React = require('react'); ReactDOM = require('react-dom'); // TODO: can we express this test with only public API? - ReactDOMComponentTree = require('../client/ReactDOMComponentTree'); + ReactDOMComponentTree = require('react-dom/src/client/ReactDOMComponentTree'); ReactDOMServer = require('react-dom/server'); }); diff --git a/packages/react-dom/src/__tests__/ReactDOMEventListener-test.js b/packages/react-dom/src/__tests__/ReactDOMEventListener-test.js index e3ddbffb6acbd..1c2d9f793c57d 100644 --- a/packages/react-dom/src/__tests__/ReactDOMEventListener-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMEventListener-test.js @@ -24,8 +24,8 @@ describe('ReactDOMEventListener', () => { React = require('react'); ReactDOM = require('react-dom'); // TODO: can we express this test with only public API? - ReactDOMComponentTree = require('../client/ReactDOMComponentTree'); - ReactDOMEventListener = require('../client/event/ReactDOMEventListener'); + ReactDOMComponentTree = require('react-dom/src/client/ReactDOMComponentTree'); + ReactDOMEventListener = require('react-dom/src/client/event/ReactDOMEventListener'); ReactTestUtils = require('react-dom/test-utils'); handleTopLevel = jest.fn(); diff --git a/packages/react-dom/src/__tests__/ReactDOMSelection-test.js b/packages/react-dom/src/__tests__/ReactDOMSelection-test.js index 74ff592b0ab75..3c80c40018ed5 100644 --- a/packages/react-dom/src/__tests__/ReactDOMSelection-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMSelection-test.js @@ -20,7 +20,7 @@ describe('ReactDOMSelection', () => { beforeEach(() => { React = require('react'); ReactDOM = require('react-dom'); - ReactDOMSelection = require('../client/ReactDOMSelection'); + ReactDOMSelection = require('react-dom/src/client/ReactDOMSelection'); invariant = require('fbjs/lib/invariant'); ({getModernOffsetsFromPoints} = ReactDOMSelection); diff --git a/packages/react-dom/src/__tests__/ReactMount-test.js b/packages/react-dom/src/__tests__/ReactMount-test.js index b14143dba3460..169a121e2f6ec 100644 --- a/packages/react-dom/src/__tests__/ReactMount-test.js +++ b/packages/react-dom/src/__tests__/ReactMount-test.js @@ -9,7 +9,7 @@ 'use strict'; -const {COMMENT_NODE} = require('../shared/HTMLNodeType'); +const {COMMENT_NODE} = require('react-dom/src/shared/HTMLNodeType'); const invariant = require('invariant'); diff --git a/packages/react-dom/src/__tests__/ReactServerRendering-test.js b/packages/react-dom/src/__tests__/ReactServerRendering-test.js index d424b5df8a1dd..4833f51c29ac4 100644 --- a/packages/react-dom/src/__tests__/ReactServerRendering-test.js +++ b/packages/react-dom/src/__tests__/ReactServerRendering-test.js @@ -34,7 +34,7 @@ describe('ReactDOMServer', () => { ExecutionEnvironment.canUseDOM = false; ReactDOMServer = require('react-dom/server'); - var DOMProperty = require('../shared/DOMProperty'); + var DOMProperty = require('react-dom/src/shared/DOMProperty'); ROOT_ATTRIBUTE_NAME = DOMProperty.ROOT_ATTRIBUTE_NAME; }); diff --git a/packages/react-dom/src/__tests__/ReactTreeTraversal-test.js b/packages/react-dom/src/__tests__/ReactTreeTraversal-test.js index 7afd0987d590c..bf9e396670c4d 100644 --- a/packages/react-dom/src/__tests__/ReactTreeTraversal-test.js +++ b/packages/react-dom/src/__tests__/ReactTreeTraversal-test.js @@ -11,7 +11,7 @@ var React = require('react'); // TODO: can we express this test with only public API? -var ReactDOMComponentTree = require('../client/ReactDOMComponentTree'); +var ReactDOMComponentTree = require('react-dom/src/client/ReactDOMComponentTree'); var ReactTestUtils = require('react-dom/test-utils'); /** diff --git a/packages/react-dom/src/__tests__/escapeTextContentForBrowser-test.js b/packages/react-dom/src/__tests__/escapeTextContentForBrowser-test.js index cd2bfedaed77c..7fdfcb6f50c6c 100644 --- a/packages/react-dom/src/__tests__/escapeTextContentForBrowser-test.js +++ b/packages/react-dom/src/__tests__/escapeTextContentForBrowser-test.js @@ -11,7 +11,7 @@ describe('escapeTextContentForBrowser', () => { // TODO: can we express this test with only public API? - var escapeTextContentForBrowser = require('../shared/escapeTextContentForBrowser'); + var escapeTextContentForBrowser = require('react-dom/src/shared/escapeTextContentForBrowser'); it('should escape boolean to string', () => { expect(escapeTextContentForBrowser(true)).toBe('true'); diff --git a/packages/react-dom/src/__tests__/inputValueTracking-test.js b/packages/react-dom/src/__tests__/inputValueTracking-test.js index c7805559838b8..7217b068be71d 100644 --- a/packages/react-dom/src/__tests__/inputValueTracking-test.js +++ b/packages/react-dom/src/__tests__/inputValueTracking-test.js @@ -13,7 +13,7 @@ var React = require('react'); var ReactDOM = require('react-dom'); var ReactTestUtils = require('react-dom/test-utils'); // TODO: can we express this test with only public API? -var inputValueTracking = require('../client/inputValueTracking'); +var inputValueTracking = require('react-dom/src/client/inputValueTracking'); var getTracker = inputValueTracking._getTrackerFromNode; diff --git a/packages/react-dom/src/__tests__/quoteAttributeValueForBrowser-test.js b/packages/react-dom/src/__tests__/quoteAttributeValueForBrowser-test.js index 75300623f61ad..e96ca19197686 100644 --- a/packages/react-dom/src/__tests__/quoteAttributeValueForBrowser-test.js +++ b/packages/react-dom/src/__tests__/quoteAttributeValueForBrowser-test.js @@ -11,7 +11,7 @@ describe('quoteAttributeValueForBrowser', () => { // TODO: can we express this test with only public API? - var quoteAttributeValueForBrowser = require('../shared/quoteAttributeValueForBrowser'); + var quoteAttributeValueForBrowser = require('react-dom/src/shared/quoteAttributeValueForBrowser'); it('should escape boolean to string', () => { expect(quoteAttributeValueForBrowser(true)).toBe('"true"'); diff --git a/packages/react-dom/src/__tests__/validateDOMNesting-test.js b/packages/react-dom/src/__tests__/validateDOMNesting-test.js index f317c211582b9..da7b7ea60509a 100644 --- a/packages/react-dom/src/__tests__/validateDOMNesting-test.js +++ b/packages/react-dom/src/__tests__/validateDOMNesting-test.js @@ -136,7 +136,7 @@ describe('ReactContextValidator', () => { jest.resetModules(); // TODO: can we express this test with only public API? - validateDOMNesting = require('../client/validateDOMNesting'); + validateDOMNesting = require('react-dom/src/client/validateDOMNesting'); }); it('allows any tag with no context', () => { diff --git a/packages/react-dom/src/client/__tests__/getNodeForCharacterOffset-test.js b/packages/react-dom/src/client/__tests__/getNodeForCharacterOffset-test.js index 05f07f572659f..eb625a0454431 100644 --- a/packages/react-dom/src/client/__tests__/getNodeForCharacterOffset-test.js +++ b/packages/react-dom/src/client/__tests__/getNodeForCharacterOffset-test.js @@ -10,7 +10,7 @@ 'use strict'; // TODO: can we express this test with only public API? -var getNodeForCharacterOffset = require('../getNodeForCharacterOffset'); +var getNodeForCharacterOffset = require('react-dom/src/client/getNodeForCharacterOffset'); // Create node from HTML string function createNode(html) { diff --git a/packages/react-dom/src/client/__tests__/setInnerHTML-test.js b/packages/react-dom/src/client/__tests__/setInnerHTML-test.js index 70b52f25c5c9b..193a8c57a05ab 100644 --- a/packages/react-dom/src/client/__tests__/setInnerHTML-test.js +++ b/packages/react-dom/src/client/__tests__/setInnerHTML-test.js @@ -10,8 +10,8 @@ 'use strict'; // TODO: can we express this test with only public API? -var setInnerHTML = require('../setInnerHTML'); -var Namespaces = require('../../shared/DOMNamespaces').Namespaces; +var setInnerHTML = require('react-dom/src/client/setInnerHTML'); +var Namespaces = require('react-dom/src/shared/DOMNamespaces').Namespaces; describe('setInnerHTML', () => { describe('when the node has innerHTML property', () => { diff --git a/packages/react-dom/src/events/__tests__/BeforeInputEventPlugin-test.js b/packages/react-dom/src/events/__tests__/BeforeInputEventPlugin-test.js index b34db2e542aa4..d00f81e800ff8 100644 --- a/packages/react-dom/src/events/__tests__/BeforeInputEventPlugin-test.js +++ b/packages/react-dom/src/events/__tests__/BeforeInputEventPlugin-test.js @@ -49,10 +49,10 @@ describe('BeforeInputEventPlugin', function() { this.ReactDOM = require('react-dom'); // TODO: can we express this test with only public API? - this.ReactDOMComponentTree = require('../../../ReactDOMComponentTree'); - this.SyntheticCompositionEvent = require('../../SyntheticCompositionEvent'); - this.SyntheticInputEvent = require('../../SyntheticInputEvent'); - this.BeforeInputEventPlugin = require('../BeforeInputEventPlugin'); + this.ReactDOMComponentTree = require('react-dom/src/client/ReactDOMComponentTree'); + this.SyntheticCompositionEvent = require('react-dom/src/client/event/SyntheticCompositionEvent'); + this.SyntheticInputEvent = require('react-dom/src/client/event/SyntheticInputEvent'); + this.BeforeInputEventPlugin = require('react-dom/src/client/event/plugins/BeforeInputEventPlugin'); } function extract(node, eventType, optionalData) { diff --git a/packages/react-dom/src/events/__tests__/ChangeEventPlugin-test.js b/packages/react-dom/src/events/__tests__/ChangeEventPlugin-test.js index 9e88452f06fb0..9af37c644eb93 100644 --- a/packages/react-dom/src/events/__tests__/ChangeEventPlugin-test.js +++ b/packages/react-dom/src/events/__tests__/ChangeEventPlugin-test.js @@ -13,8 +13,8 @@ var React = require('react'); var ReactDOM = require('react-dom'); var ReactTestUtils = require('react-dom/test-utils'); // TODO: can we express this test with only public API? -var ChangeEventPlugin = require('../ChangeEventPlugin'); -var inputValueTracking = require('../../../inputValueTracking'); +var ChangeEventPlugin = require('react-dom/src/client/event/plugins/ChangeEventPlugin'); +var inputValueTracking = require('react-dom/src/client/inputValueTracking'); function getTrackedValue(elem) { var tracker = inputValueTracking._getTrackerFromNode(elem); diff --git a/packages/react-dom/src/events/__tests__/EnterLeaveEventPlugin-test.js b/packages/react-dom/src/events/__tests__/EnterLeaveEventPlugin-test.js index cc261126d1c20..38121ba48cd8a 100644 --- a/packages/react-dom/src/events/__tests__/EnterLeaveEventPlugin-test.js +++ b/packages/react-dom/src/events/__tests__/EnterLeaveEventPlugin-test.js @@ -23,8 +23,8 @@ describe('EnterLeaveEventPlugin', () => { ReactDOM = require('react-dom'); ReactTestUtils = require('react-dom/test-utils'); // TODO: can we express this test with only public API? - ReactDOMComponentTree = require('../../../ReactDOMComponentTree'); - EnterLeaveEventPlugin = require('../EnterLeaveEventPlugin'); + ReactDOMComponentTree = require('react-dom/src/client/ReactDOMComponentTree'); + EnterLeaveEventPlugin = require('react-dom/src/client/event/plugins/EnterLeaveEventPlugin'); }); it('should set relatedTarget properly in iframe', () => { diff --git a/packages/react-dom/src/events/__tests__/FallbackCompositionState-test.js b/packages/react-dom/src/events/__tests__/FallbackCompositionState-test.js index 36fdbdad9d605..0420d73bc1fba 100644 --- a/packages/react-dom/src/events/__tests__/FallbackCompositionState-test.js +++ b/packages/react-dom/src/events/__tests__/FallbackCompositionState-test.js @@ -16,7 +16,7 @@ describe('FallbackCompositionState', () => { beforeEach(() => { // TODO: can we express this test with only public API? - FallbackCompositionState = require('../FallbackCompositionState'); + FallbackCompositionState = require('react-dom/src/client/event/plugins/FallbackCompositionState'); }); function getInput() { diff --git a/packages/react-dom/src/events/__tests__/SelectEventPlugin-test.js b/packages/react-dom/src/events/__tests__/SelectEventPlugin-test.js index 03c915f0defe7..2ae0e4e427123 100644 --- a/packages/react-dom/src/events/__tests__/SelectEventPlugin-test.js +++ b/packages/react-dom/src/events/__tests__/SelectEventPlugin-test.js @@ -30,8 +30,8 @@ describe('SelectEventPlugin', () => { ReactDOM = require('react-dom'); ReactTestUtils = require('react-dom/test-utils'); // TODO: can we express this test with only public API? - ReactDOMComponentTree = require('../../../ReactDOMComponentTree'); - SelectEventPlugin = require('../SelectEventPlugin'); + ReactDOMComponentTree = require('react-dom/src/client/ReactDOMComponentTree'); + SelectEventPlugin = require('react-dom/src/client/event/plugins/SelectEventPlugin'); }); it('should skip extraction if no listeners are present', () => { diff --git a/packages/react-dom/src/events/__tests__/SyntheticClipboardEvent-test.js b/packages/react-dom/src/events/__tests__/SyntheticClipboardEvent-test.js index b0e2f63a04942..5e33eba008b7b 100644 --- a/packages/react-dom/src/events/__tests__/SyntheticClipboardEvent-test.js +++ b/packages/react-dom/src/events/__tests__/SyntheticClipboardEvent-test.js @@ -16,9 +16,9 @@ describe('SyntheticClipboardEvent', () => { beforeEach(() => { // TODO: can we express this test with only public API? - SyntheticClipboardEvent = require('../SyntheticClipboardEvent'); + SyntheticClipboardEvent = require('react-dom/src/client/event/SyntheticClipboardEvent'); createEvent = function(nativeEvent) { - var target = require('../getEventTarget')(nativeEvent); + var target = require('react-dom/src/client/event/getEventTarget')(nativeEvent); return SyntheticClipboardEvent.getPooled({}, '', nativeEvent, target); }; }); diff --git a/packages/react-dom/src/events/__tests__/SyntheticEvent-test.js b/packages/react-dom/src/events/__tests__/SyntheticEvent-test.js index 9abc77ea86875..193870ab4e2c3 100644 --- a/packages/react-dom/src/events/__tests__/SyntheticEvent-test.js +++ b/packages/react-dom/src/events/__tests__/SyntheticEvent-test.js @@ -25,7 +25,7 @@ describe('SyntheticEvent', () => { ReactTestUtils = require('react-dom/test-utils'); createEvent = function(nativeEvent) { - var target = require('../getEventTarget')(nativeEvent); + var target = require('react-dom/src/client/event/getEventTarget')(nativeEvent); return SyntheticEvent.getPooled({}, '', nativeEvent, target); }; }); diff --git a/packages/react-dom/src/events/__tests__/SyntheticKeyboardEvent-test.js b/packages/react-dom/src/events/__tests__/SyntheticKeyboardEvent-test.js index ab3e40262079c..8f90e30b1d8ac 100644 --- a/packages/react-dom/src/events/__tests__/SyntheticKeyboardEvent-test.js +++ b/packages/react-dom/src/events/__tests__/SyntheticKeyboardEvent-test.js @@ -17,13 +17,13 @@ describe('SyntheticKeyboardEvent', () => { beforeEach(() => { // Mock getEventCharCode for proper unit testing - jest.mock('../getEventCharCode'); - getEventCharCode = require('../getEventCharCode'); + jest.mock('react-dom/src/client/event/getEventCharCode'); + getEventCharCode = require('react-dom/src/client/event/getEventCharCode'); // TODO: can we express this test with only public API? - SyntheticKeyboardEvent = require('../SyntheticKeyboardEvent'); + SyntheticKeyboardEvent = require('react-dom/src/client/event/SyntheticKeyboardEvent'); createEvent = function(nativeEvent) { - var target = require('../getEventTarget')(nativeEvent); + var target = require('react-dom/src/client/event/getEventTarget')(nativeEvent); return SyntheticKeyboardEvent.getPooled({}, '', nativeEvent, target); }; }); diff --git a/packages/react-dom/src/events/__tests__/SyntheticWheelEvent-test.js b/packages/react-dom/src/events/__tests__/SyntheticWheelEvent-test.js index 229a93f68fe5f..299d3c3f77116 100644 --- a/packages/react-dom/src/events/__tests__/SyntheticWheelEvent-test.js +++ b/packages/react-dom/src/events/__tests__/SyntheticWheelEvent-test.js @@ -16,10 +16,10 @@ describe('SyntheticWheelEvent', () => { beforeEach(() => { // TODO: can we express this test with only public API? - SyntheticWheelEvent = require('../SyntheticWheelEvent'); + SyntheticWheelEvent = require('react-dom/src/client/event/SyntheticWheelEvent'); createEvent = function(nativeEvent) { - var target = require('../getEventTarget')(nativeEvent); + var target = require('react-dom/src/client/event/getEventTarget')(nativeEvent); return SyntheticWheelEvent.getPooled({}, '', nativeEvent, target); }; }); diff --git a/packages/react-dom/src/events/__tests__/getEventCharCode-test.js b/packages/react-dom/src/events/__tests__/getEventCharCode-test.js index 3787151c47274..e87ff069a413c 100644 --- a/packages/react-dom/src/events/__tests__/getEventCharCode-test.js +++ b/packages/react-dom/src/events/__tests__/getEventCharCode-test.js @@ -10,7 +10,7 @@ 'use strict'; // TODO: can we express this test with only public API? -var getEventCharCode = require('../getEventCharCode'); +var getEventCharCode = require('react-dom/src/client/event/getEventCharCode'); describe('getEventCharCode', () => { describe('when charCode is present in nativeEvent', () => { diff --git a/packages/react-dom/src/events/__tests__/getEventKey-test.js b/packages/react-dom/src/events/__tests__/getEventKey-test.js index 4942911d4389f..0223685a436bb 100644 --- a/packages/react-dom/src/events/__tests__/getEventKey-test.js +++ b/packages/react-dom/src/events/__tests__/getEventKey-test.js @@ -10,7 +10,7 @@ 'use strict'; // TODO: can we express this test with only public API? -var getEventKey = require('../getEventKey'); +var getEventKey = require('react-dom/src/client/event/getEventKey'); describe('getEventKey', () => { describe('when key is implemented in a browser', () => { diff --git a/packages/react-native-renderer/src/ReactNativeRenderer.js b/packages/react-native-renderer/src/ReactNativeRenderer.js index b6d91623985c4..4f72a12a825ab 100644 --- a/packages/react-native-renderer/src/ReactNativeRenderer.js +++ b/packages/react-native-renderer/src/ReactNativeRenderer.js @@ -29,7 +29,7 @@ const findNumericNodeHandle = require('./findNumericNodeHandle'); import type {ReactNativeType} from 'ReactNativeTypes'; import type {ReactNodeList} from 'ReactTypes'; -require('ReactNativeInjection'); +require('./ReactNativeInjection'); ReactGenericBatching.injection.injectFiberBatchedUpdates( ReactNativeFiberRenderer.batchedUpdates, diff --git a/packages/react-native-renderer/src/__tests__/ReactNativeAttributePayload-test.js b/packages/react-native-renderer/src/__tests__/ReactNativeAttributePayload-test.js index 99135d8b570e3..124e26a4e1c45 100644 --- a/packages/react-native-renderer/src/__tests__/ReactNativeAttributePayload-test.js +++ b/packages/react-native-renderer/src/__tests__/ReactNativeAttributePayload-test.js @@ -7,8 +7,8 @@ */ 'use strict'; -var ReactNativeAttributePayload = require('../ReactNativeAttributePayload'); -var ReactNativePropRegistry = require('../ReactNativePropRegistry'); +var ReactNativeAttributePayload = require('react-native-renderer/src/ReactNativeAttributePayload'); +var ReactNativePropRegistry = require('react-native-renderer/src/ReactNativePropRegistry'); var diff = ReactNativeAttributePayload.diff; diff --git a/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.js b/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.js index 3beeb5f439bf2..6a23e5a43c904 100644 --- a/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.js +++ b/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.js @@ -69,10 +69,10 @@ beforeEach(() => { RCTEventEmitter = require('RCTEventEmitter'); React = require('react'); ReactNative = require('react-native-renderer'); - ReactNativeBridgeEventPlugin = require('../ReactNativeBridgeEventPlugin'); + ReactNativeBridgeEventPlugin = require('react-native-renderer/src/ReactNativeBridgeEventPlugin'); ResponderEventPlugin = require('shared/event/plugins/ResponderEventPlugin'); UIManager = require('UIManager'); - createReactNativeComponentClass = require('../createReactNativeComponentClass'); + createReactNativeComponentClass = require('react-native-renderer/src/createReactNativeComponentClass'); }); it('fails if unknown/unsupported event types are dispatched', () => { diff --git a/packages/react-native-renderer/src/__tests__/ReactNativeMount-test.js b/packages/react-native-renderer/src/__tests__/ReactNativeMount-test.js index 8f6e5b63326b3..374fea72b9e22 100644 --- a/packages/react-native-renderer/src/__tests__/ReactNativeMount-test.js +++ b/packages/react-native-renderer/src/__tests__/ReactNativeMount-test.js @@ -21,7 +21,7 @@ describe('ReactNative', () => { React = require('react'); ReactNative = require('react-native-renderer'); UIManager = require('UIManager'); - createReactNativeComponentClass = require('../createReactNativeComponentClass'); + createReactNativeComponentClass = require('react-native-renderer/src/createReactNativeComponentClass'); }); it('should be able to create and render a native component', () => { diff --git a/packages/react-native-renderer/src/__tests__/createReactNativeComponentClass-test.js b/packages/react-native-renderer/src/__tests__/createReactNativeComponentClass-test.js index aba3b8acc286d..70166d57ecdee 100644 --- a/packages/react-native-renderer/src/__tests__/createReactNativeComponentClass-test.js +++ b/packages/react-native-renderer/src/__tests__/createReactNativeComponentClass-test.js @@ -17,7 +17,7 @@ describe('createReactNativeComponentClass', () => { beforeEach(() => { jest.resetModules(); - createReactNativeComponentClass = require('../createReactNativeComponentClass'); + createReactNativeComponentClass = require('react-native-renderer/src/createReactNativeComponentClass'); React = require('react'); ReactNative = require('react-native-renderer'); }); diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalPerf-test.js b/packages/react-reconciler/src/__tests__/ReactIncrementalPerf-test.js index 38dba350c55c1..f7a28614a5bc9 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalPerf-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalPerf-test.js @@ -116,8 +116,8 @@ describe('ReactDebugFiberPerf', () => { React = require('react'); ReactNoop = require('react-noop-renderer'); // TODO: can we express this test with only public API? - ReactCoroutine = require('../isomorphic/ReactCoroutine'); - ReactPortal = require('../isomorphic/ReactPortal'); + ReactCoroutine = require('react-reconciler/src/isomorphic/ReactCoroutine'); + ReactPortal = require('react-reconciler/src/isomorphic/ReactPortal'); PropTypes = require('prop-types'); }); diff --git a/packages/react-reconciler/src/__tests__/ReactPersistent-test.js b/packages/react-reconciler/src/__tests__/ReactPersistent-test.js index 61fae0ec12119..a8d8a6eec8064 100644 --- a/packages/react-reconciler/src/__tests__/ReactPersistent-test.js +++ b/packages/react-reconciler/src/__tests__/ReactPersistent-test.js @@ -24,7 +24,7 @@ describe('ReactPersistent', () => { React = require('react'); ReactNoop = require('react-noop-renderer'); - ReactPortal = require('../isomorphic/ReactPortal'); + ReactPortal = require('react-reconciler/src/isomorphic/ReactPortal'); }); const DEFAULT_ROOT_ID = 'persistent-test'; diff --git a/packages/shared/__tests__/ReactErrorUtils-test.js b/packages/shared/__tests__/ReactErrorUtils-test.js index 6f6d09b07b6e1..dca4cef43a100 100644 --- a/packages/shared/__tests__/ReactErrorUtils-test.js +++ b/packages/shared/__tests__/ReactErrorUtils-test.js @@ -14,7 +14,7 @@ var ReactErrorUtils; describe('ReactErrorUtils', () => { beforeEach(() => { // TODO: can we express this test with only public API? - ReactErrorUtils = require('../ReactErrorUtils'); + ReactErrorUtils = require('shared/ReactErrorUtils'); }); // Run tests in both DEV and production @@ -36,7 +36,7 @@ describe('ReactErrorUtils', () => { }; jest.resetModules(); - ReactErrorUtils = require('../ReactErrorUtils'); + ReactErrorUtils = require('shared/ReactErrorUtils'); }); afterEach(() => { @@ -161,9 +161,9 @@ describe('ReactErrorUtils', () => { }); it('handles nested errors in separate renderers', () => { - const ReactErrorUtils1 = require('../ReactErrorUtils'); + const ReactErrorUtils1 = require('shared/ReactErrorUtils'); jest.resetModules(); - const ReactErrorUtils2 = require('../ReactErrorUtils'); + const ReactErrorUtils2 = require('shared/ReactErrorUtils'); expect(ReactErrorUtils1).not.toEqual(ReactErrorUtils2); let ops = []; diff --git a/packages/shared/__tests__/reactProdInvariant-test.js b/packages/shared/__tests__/reactProdInvariant-test.js index 31689d4cbeab4..7cd2e88a78636 100644 --- a/packages/shared/__tests__/reactProdInvariant-test.js +++ b/packages/shared/__tests__/reactProdInvariant-test.js @@ -13,7 +13,7 @@ var reactProdInvariant; describe('reactProdInvariant', () => { beforeEach(() => { jest.resetModules(); - reactProdInvariant = require('../reactProdInvariant'); + reactProdInvariant = require('shared/reactProdInvariant'); }); it('should throw with the correct number of `%s`s in the URL', () => {