forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: The current way the Jest preset work requires the different files to be in `<rootDir>/node_modules/react-native`. This is not necessarily true - especially in monorepoes. If we instead do `require.resolve`, we do not need to do `rootDir` replacement in Jest. Having a JS file as preset has been supported since Jest 23.0.0: jestjs/jest#6185 Changelog: ---------- [General] [Fixed] - use `require.resolve` in `jest-preset` Pull Request resolved: facebook#22972 Differential Revision: D13662758 Pulled By: hramos fbshipit-source-id: ca79b5b89d9d05c6fe639b0d88619858e8d05da7
- Loading branch information
1 parent
3e9339e
commit 2ee8352
Showing
3 changed files
with
42 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* 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 | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const dir = __dirname; | ||
|
||
module.exports = { | ||
haste: { | ||
defaultPlatform: 'ios', | ||
platforms: ['android', 'ios', 'native'], | ||
hasteImplModulePath: require.resolve('./jest/hasteImpl.js'), | ||
providesModuleNodeModules: ['react-native'], | ||
}, | ||
moduleFileExtensions: ['js', 'json', 'jsx', 'node', 'ts', 'tsx'], | ||
moduleNameMapper: { | ||
'^React$': require.resolve('react'), | ||
}, | ||
modulePathIgnorePatterns: [`${dir}/Libraries/react-native/`], | ||
transform: { | ||
'^.+\\.(js|ts|tsx)$': 'babel-jest', | ||
'^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve( | ||
'./jest/assetFileTransformer.js', | ||
), | ||
}, | ||
transformIgnorePatterns: [ | ||
'node_modules/(?!(jest-)?react-native|react-clone-referenced-element)', | ||
], | ||
testMatch: [ | ||
'**/__tests__/**/*.(js|ts|tsx)', | ||
'**/?(*.)+(spec|test).(js|ts|tsx)', | ||
], | ||
setupFiles: [require.resolve('./jest/setup.js')], | ||
testEnvironment: 'node', | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters