Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Jest and remove hacks #11372

Merged
merged 3 commits into from
Oct 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"babel-cli": "^6.6.5",
"babel-core": "^6.0.0",
"babel-eslint": "^7.1.0",
"babel-jest": "21.2.0",
"babel-jest": "^21.3.0-beta.4",
"babel-plugin-check-es2015-constants": "^6.5.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-syntax-trailing-function-commas": "^6.5.0",
Expand Down Expand Up @@ -53,6 +53,7 @@
"eslint-plugin-flowtype": "^2.25.0",
"eslint-plugin-react": "^6.7.1",
"eslint-plugin-react-internal": "file:./scripts/eslint-rules",
"expect": "^21.3.0-beta.4",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jest-matchers was renamed to expect.

"fbjs": "^0.8.16",
"fbjs-scripts": "^0.6.0",
"filesize": "^3.5.6",
Expand All @@ -63,11 +64,10 @@
"gzip-js": "~0.3.2",
"gzip-size": "^3.0.0",
"jasmine-check": "^1.0.0-rc.0",
"jest": "21.2.1",
"jest-config": "21.2.1",
"jest-jasmine2": "21.2.1",
"jest-matchers": "20.1.0-delta.1",
"jest-runtime": "21.2.1",
"jest": "^21.3.0-beta.4",
"jest-config": "^21.3.0-beta.4",
"jest-jasmine2": "^21.3.0-beta.4",
"jest-runtime": "^21.3.0-beta.4",
"merge-stream": "^1.0.0",
"minimist": "^1.2.0",
"ncp": "^2.0.0",
Expand Down Expand Up @@ -115,9 +115,6 @@
"transform": {
".*": "./scripts/jest/preprocessor.js"
},
"transformIgnorePatterns": [
"/node_modules/(?!react|shared|events)"
],
"setupFiles": [
"./scripts/jest/setup.js",
"./scripts/jest/environment.js"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var React;
var ReactNativeCS;

jest.mock('shared/ReactFeatureFlags', () =>
require('react-cs-renderer/src/ReactNativeCSFeatureFlags'),
require('../ReactNativeCSFeatureFlags'),
);

describe('ReactNativeCS', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/__tests__/EventPluginHub-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

'use strict';

jest.mock('react-dom/src/events/isEventSupported');
jest.mock('../events/isEventSupported');

describe('EventPluginHub', () => {
var React;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ describe('ReactBrowserEventEmitter', () => {
EventPluginRegistry = require('events/EventPluginRegistry');
React = require('react');
ReactDOM = require('react-dom');
ReactDOMComponentTree = require('react-dom/src/client/ReactDOMComponentTree');
ReactBrowserEventEmitter = require('react-dom/src/events/ReactBrowserEventEmitter');
ReactDOMComponentTree = require('../client/ReactDOMComponentTree');
ReactBrowserEventEmitter = require('../events/ReactBrowserEventEmitter');
ReactTestUtils = require('react-dom/test-utils');
TapEventPlugin = require('react-dom/src/events/TapEventPlugin');
TapEventPlugin = require('../events/TapEventPlugin');

var container = document.createElement('div');

Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('react-dom/src/client/inputValueTracking');
inputValueTracking = require('../client/inputValueTracking');
});

describe('updateDOM', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('react-dom/src/client/ReactDOMComponentTree');
ReactDOMComponentTree = require('../client/ReactDOMComponentTree');
ReactDOMServer = require('react-dom/server');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('react-dom/src/client/ReactDOMComponentTree');
ReactDOMEventListener = require('react-dom/src/events/ReactDOMEventListener');
ReactDOMComponentTree = require('../client/ReactDOMComponentTree');
ReactDOMEventListener = require('../events/ReactDOMEventListener');
ReactTestUtils = require('react-dom/test-utils');

handleTopLevel = jest.fn();
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/__tests__/ReactDOMInput-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('ReactDOMInput', () => {
ReactDOMServer = require('react-dom/server');
ReactTestUtils = require('react-dom/test-utils');
// TODO: can we express this test with only public API?
inputValueTracking = require('react-dom/src/client/inputValueTracking');
inputValueTracking = require('../client/inputValueTracking');
spyOn(console, 'error');
});

Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/__tests__/ReactDOMSelection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('ReactDOMSelection', () => {
beforeEach(() => {
React = require('react');
ReactDOM = require('react-dom');
ReactDOMSelection = require('react-dom/src/client/ReactDOMSelection');
ReactDOMSelection = require('../client/ReactDOMSelection');
invariant = require('fbjs/lib/invariant');

({getModernOffsetsFromPoints} = ReactDOMSelection);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/__tests__/ReactMount-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

'use strict';

const {COMMENT_NODE} = require('react-dom/src/shared/HTMLNodeType');
const {COMMENT_NODE} = require('../shared/HTMLNodeType');

const invariant = require('invariant');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ describe('ReactDOMServer', () => {
ExecutionEnvironment.canUseDOM = false;
ReactDOMServer = require('react-dom/server');

var DOMProperty = require('react-dom/src/shared/DOMProperty');
// TODO: can we express this test with only public API?
var DOMProperty = require('../shared/DOMProperty');
ROOT_ATTRIBUTE_NAME = DOMProperty.ROOT_ATTRIBUTE_NAME;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

describe('escapeTextContentForBrowser', () => {
// TODO: can we express this test with only public API?
var escapeTextContentForBrowser = require('react-dom/src/shared/escapeTextContentForBrowser');
var escapeTextContentForBrowser = require('../shared/escapeTextContentForBrowser');

it('should escape boolean to string', () => {
expect(escapeTextContentForBrowser(true)).toBe('true');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('react-dom/src/client/inputValueTracking');
var inputValueTracking = require('../client/inputValueTracking');

var getTracker = inputValueTracking._getTrackerFromNode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

describe('quoteAttributeValueForBrowser', () => {
// TODO: can we express this test with only public API?
var quoteAttributeValueForBrowser = require('react-dom/src/shared/quoteAttributeValueForBrowser');
var quoteAttributeValueForBrowser = require('../shared/quoteAttributeValueForBrowser');

it('should escape boolean to string', () => {
expect(quoteAttributeValueForBrowser(true)).toBe('"true"');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('ReactContextValidator', () => {
jest.resetModules();

// TODO: can we express this test with only public API?
validateDOMNesting = require('react-dom/src/client/validateDOMNesting');
validateDOMNesting = require('../client/validateDOMNesting');
});

it('allows any tag with no context', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'use strict';

// TODO: can we express this test with only public API?
var getNodeForCharacterOffset = require('react-dom/src/client/getNodeForCharacterOffset');
var getNodeForCharacterOffset = require('../getNodeForCharacterOffset');

// Create node from HTML string
function createNode(html) {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/client/__tests__/setInnerHTML-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
'use strict';

// TODO: can we express this test with only public API?
var setInnerHTML = require('react-dom/src/client/setInnerHTML');
var Namespaces = require('react-dom/src/shared/DOMNamespaces').Namespaces;
var setInnerHTML = require('../setInnerHTML');
var Namespaces = require('../../shared/DOMNamespaces').Namespaces;

describe('setInnerHTML', () => {
describe('when the node has innerHTML property', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('react-dom/src/client/ReactDOMComponentTree');
this.SyntheticCompositionEvent = require('react-dom/src/events/SyntheticCompositionEvent');
this.SyntheticInputEvent = require('react-dom/src/events/SyntheticInputEvent');
this.BeforeInputEventPlugin = require('react-dom/src/events/BeforeInputEventPlugin');
this.ReactDOMComponentTree = require('../../client//ReactDOMComponentTree');
this.SyntheticCompositionEvent = require('../SyntheticCompositionEvent');
this.SyntheticInputEvent = require('../SyntheticInputEvent');
this.BeforeInputEventPlugin = require('../BeforeInputEventPlugin');
}

function extract(node, eventType, optionalData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('react-dom/src/client/ReactDOMComponentTree');
EnterLeaveEventPlugin = require('react-dom/src/events/EnterLeaveEventPlugin');
ReactDOMComponentTree = require('../../client/ReactDOMComponentTree');
EnterLeaveEventPlugin = require('../EnterLeaveEventPlugin');
});

it('should set relatedTarget properly in iframe', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('FallbackCompositionState', () => {

beforeEach(() => {
// TODO: can we express this test with only public API?
FallbackCompositionState = require('react-dom/src/events/FallbackCompositionState');
FallbackCompositionState = require('../FallbackCompositionState');
});

function getInput() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('react-dom/src/client/ReactDOMComponentTree');
SelectEventPlugin = require('react-dom/src/events/SelectEventPlugin');
ReactDOMComponentTree = require('../../client/ReactDOMComponentTree');
SelectEventPlugin = require('../SelectEventPlugin');
});

it('should skip extraction if no listeners are present', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ describe('SyntheticClipboardEvent', () => {

beforeEach(() => {
// TODO: can we express this test with only public API?
SyntheticClipboardEvent = require('react-dom/src/events/SyntheticClipboardEvent');
SyntheticClipboardEvent = require('../SyntheticClipboardEvent');
createEvent = function(nativeEvent) {
var target = require('react-dom/src/events/getEventTarget')(nativeEvent);
var target = require('../getEventTarget')(nativeEvent);
return SyntheticClipboardEvent.getPooled({}, '', nativeEvent, target);
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('SyntheticEvent', () => {
ReactTestUtils = require('react-dom/test-utils');

createEvent = function(nativeEvent) {
var target = require('react-dom/src/events/getEventTarget')(nativeEvent);
var target = require('../getEventTarget')(nativeEvent);
return SyntheticEvent.getPooled({}, '', nativeEvent, target);
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ describe('SyntheticKeyboardEvent', () => {

beforeEach(() => {
// Mock getEventCharCode for proper unit testing
jest.mock('react-dom/src/events/getEventCharCode');
getEventCharCode = require('react-dom/src/events/getEventCharCode');
jest.mock('../getEventCharCode');
getEventCharCode = require('../getEventCharCode');

// TODO: can we express this test with only public API?
SyntheticKeyboardEvent = require('react-dom/src/events/SyntheticKeyboardEvent');
SyntheticKeyboardEvent = require('../SyntheticKeyboardEvent');
createEvent = function(nativeEvent) {
var target = require('react-dom/src/events/getEventTarget')(nativeEvent);
var target = require('../getEventTarget')(nativeEvent);
return SyntheticKeyboardEvent.getPooled({}, '', nativeEvent, target);
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ describe('SyntheticWheelEvent', () => {

beforeEach(() => {
// TODO: can we express this test with only public API?
SyntheticWheelEvent = require('react-dom/src/events/SyntheticWheelEvent');
SyntheticWheelEvent = require('../SyntheticWheelEvent');

createEvent = function(nativeEvent) {
var target = require('react-dom/src/events/getEventTarget')(nativeEvent);
var target = require('../getEventTarget')(nativeEvent);
return SyntheticWheelEvent.getPooled({}, '', nativeEvent, target);
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'use strict';

// TODO: can we express this test with only public API?
var getEventCharCode = require('react-dom/src/events/getEventCharCode');
var getEventCharCode = require('../getEventCharCode');

describe('getEventCharCode', () => {
describe('when charCode is present in nativeEvent', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'use strict';

// TODO: can we express this test with only public API?
var getEventKey = require('react-dom/src/events/getEventKey');
var getEventKey = require('../getEventKey');

describe('getEventKey', () => {
describe('when key is implemented in a browser', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/
'use strict';

var ReactNativeAttributePayload = require('react-native-renderer/src/ReactNativeAttributePayload');
var ReactNativePropRegistry = require('react-native-renderer/src/ReactNativePropRegistry');
var ReactNativeAttributePayload = require('../ReactNativeAttributePayload');
var ReactNativePropRegistry = require('../ReactNativePropRegistry');

var diff = ReactNativeAttributePayload.diff;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ beforeEach(() => {
RCTEventEmitter = require('RCTEventEmitter');
React = require('react');
ReactNative = require('react-native-renderer');
ReactNativeBridgeEventPlugin = require('react-native-renderer/src/ReactNativeBridgeEventPlugin');
ReactNativeBridgeEventPlugin = require('../ReactNativeBridgeEventPlugin');
ResponderEventPlugin = require('events/ResponderEventPlugin');
UIManager = require('UIManager');
createReactNativeComponentClass = require('react-native-renderer/src/createReactNativeComponentClass');
createReactNativeComponentClass = require('../createReactNativeComponentClass');
});

it('fails if unknown/unsupported event types are dispatched', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('ReactNative', () => {
React = require('react');
ReactNative = require('react-native-renderer');
UIManager = require('UIManager');
createReactNativeComponentClass = require('react-native-renderer/src/createReactNativeComponentClass');
createReactNativeComponentClass = require('../createReactNativeComponentClass');
});

it('should be able to create and render a native component', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('createReactNativeComponentClass', () => {
beforeEach(() => {
jest.resetModules();

createReactNativeComponentClass = require('react-native-renderer/src/createReactNativeComponentClass');
createReactNativeComponentClass = require('../createReactNativeComponentClass');
React = require('react');
ReactNative = require('react-native-renderer');
});
Expand Down
2 changes: 1 addition & 1 deletion packages/react-noop-renderer/src/ReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var ReactFiberReconciler = require('react-reconciler');
var ReactFeatureFlags = require('shared/ReactFeatureFlags');
var ReactInstanceMap = require('shared/ReactInstanceMap');
var emptyObject = require('fbjs/lib/emptyObject');
var expect = require('jest-matchers');
var expect = require('expect');

const UPDATE_SIGNAL = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -935,11 +935,9 @@ describe('ReactIncrementalErrorHandling', () => {
function initReactFiberErrorLoggerMock(mock) {
jest.resetModules();
if (mock) {
// TODO: direct imports like some-package/src/* are bad. Fix me.
jest.mock('react-reconciler/src/ReactFiberErrorLogger');
jest.mock('../ReactFiberErrorLogger');
} else {
// TODO: direct imports like some-package/src/* are bad. Fix me.
jest.unmock('react-reconciler/src/ReactFiberErrorLogger');
jest.unmock('../ReactFiberErrorLogger');
}
React = require('react');
ReactNoop = require('react-noop-renderer');
Expand Down Expand Up @@ -1035,8 +1033,7 @@ describe('ReactIncrementalErrorHandling', () => {

const logCapturedErrorCalls = [];

// TODO: direct imports like some-package/src/* are bad. Fix me.
const ReactFiberErrorLogger = require('react-reconciler/src/ReactFiberErrorLogger');
const ReactFiberErrorLogger = require('../ReactFiberErrorLogger');
ReactFiberErrorLogger.logCapturedError.mockImplementation(
capturedError => {
logCapturedErrorCalls.push(capturedError);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('ReactDebugFiberPerf', () => {
ReactNoop = require('react-noop-renderer');
ReactCallReturn = require('react-call-return');
// TODO: can we express this test with only public API?
ReactPortal = require('react-reconciler/src/ReactPortal');
ReactPortal = require('../ReactPortal');
PropTypes = require('prop-types');
});

Expand Down
Loading