Files
react-native/jest/renderer.js
James IdeandFacebook Github Bot 59749f527a Migrate Jest setup scripts from Haste to path-based requires (#24753)
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
2019-05-08 06:59:47 -07:00

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);
};