mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: This is another step in moving RN towards standard path-based requires. All the requires in Jest's setup script have been rewritten to use relative requires. This commit uses relative requires instead of `react-native/...` so that if Facebook were to stop syncing out certain folders and therefore remove code from the react-native package, internal code at Facebook would not need to change. [General] [Changed] - Migrate Jest setup scripts from Haste to path-based requires Pull Request resolved: https://github.com/facebook/react-native/pull/24753 Differential Revision: D15258238 Pulled By: cpojer fbshipit-source-id: aa05dc8ea2e4ba195226e8ec7ba6482b7de03240
30 lines
713 B
JavaScript
30 lines
713 B
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @emails oncall+react_native
|
|
* @flow
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const React = require('react');
|
|
|
|
const TestRenderer = require('react-test-renderer');
|
|
const ShallowRenderer = require('react-test-renderer/shallow');
|
|
|
|
const renderer = new ShallowRenderer();
|
|
|
|
export const shallow = (Component: React.Element<any>) => {
|
|
const Wrapper = (): React.Element<any> => Component;
|
|
|
|
return renderer.render(<Wrapper />);
|
|
};
|
|
|
|
export const create = (Component: React.Element<any>) => {
|
|
return TestRenderer.create(Component);
|
|
};
|