mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Summary: This implements the proposal to split the Jest preset (and dependencies) out into a separate package: https://github.com/react-native-community/discussions-and-proposals/pull/926 - `react-native` has an optional peer dependency on `react-native/jest-preset` - `react-native/jest-preset.js` throws when `react-native/jest-preset` isn't installed and instructs the user to add it to migrate - `react-native/jest-preset` may be used directly as a Jest preset ## Changelog: [General][Breaking] - Move Jest preset to new `react-native/jest-preset` package Pull Request resolved: https://github.com/facebook/react-native/pull/55169 Test Plan: The jest preset is used, with some modifications, in `facebook/react-native` itself and CI should confirm that the changes work. Running `jest` on the repo similarly validates that the preset still works. Otherwise, nothing has changed and the easiest way to test this is to use the preset in an existing project and try both `preset` set to the current value and `preset` set to `"react-native/jest-preset"` Reviewed By: cipolleschi Differential Revision: D91700684 Pulled By: huntie fbshipit-source-id: ee4a7d3ceb4934a3d0f7558d93dc601ea4b8dfa8
80 lines
2.1 KiB
JavaScript
80 lines
2.1 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow strict
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
// $FlowFixMe[cannot-resolve-module]
|
|
// $FlowFixMe[untyped-import]
|
|
const {defaults} = require('jest-config');
|
|
|
|
const PODS_LOCATIONS = [
|
|
'packages/rn-tester/Pods',
|
|
'private/helloworld/ios/Pods',
|
|
];
|
|
|
|
module.exports = {
|
|
transform: {
|
|
'^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$':
|
|
'<rootDir>/packages/jest-preset/jest/assetFileTransformer.js',
|
|
'.*': './jest/preprocessor.js',
|
|
},
|
|
resolver: './packages/jest-preset/jest/resolver.js',
|
|
setupFiles: ['./packages/jest-preset/jest/local-setup.js'],
|
|
fakeTimers: {
|
|
enableGlobally: true,
|
|
legacyFakeTimers: false,
|
|
},
|
|
snapshotFormat: {
|
|
escapeString: true,
|
|
printBasicPrototype: true,
|
|
},
|
|
// This allows running Meta-internal tests with the `-test.fb.js` suffix.
|
|
testRegex: '/__tests__/.*-test(\\.fb)?\\.js$',
|
|
testPathIgnorePatterns: [
|
|
'/node_modules/',
|
|
'<rootDir>/packages/react-native/sdks',
|
|
'<rootDir>/packages/react-native/Libraries/Renderer',
|
|
'<rootDir>/packages/react-native/sdks/hermes/',
|
|
...PODS_LOCATIONS,
|
|
] /*:: as $ReadOnlyArray<string> */,
|
|
transformIgnorePatterns: ['node_modules/(?!@react-native/)'],
|
|
haste: {
|
|
defaultPlatform: 'ios',
|
|
platforms: ['ios', 'android'],
|
|
},
|
|
moduleFileExtensions: [
|
|
'fb.js',
|
|
...defaults.moduleFileExtensions,
|
|
] /*:: as $ReadOnlyArray<string> */,
|
|
modulePathIgnorePatterns: [
|
|
'scripts/.*/__fixtures__/',
|
|
'<rootDir>/packages/react-native/sdks/hermes/',
|
|
...PODS_LOCATIONS,
|
|
] /*:: as $ReadOnlyArray<string> */,
|
|
unmockedModulePathPatterns: [
|
|
'node_modules/react/',
|
|
'packages/react-native/Libraries/Renderer',
|
|
'promise',
|
|
'source-map',
|
|
'fastpath',
|
|
'denodeify',
|
|
],
|
|
testEnvironment: 'node',
|
|
collectCoverageFrom: [
|
|
'packages/react-native/Libraries/**/*.js',
|
|
'packages/react-native/src/**/*.js',
|
|
],
|
|
coveragePathIgnorePatterns: [
|
|
'/__tests__/',
|
|
'/vendor/',
|
|
'<rootDir>/packages/react-native/Libraries/react-native/',
|
|
],
|
|
};
|