mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Mock prettier import through actual require to prepare for prettier v3 (#52843)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52843 Changelog: [Internal] Reviewed By: pieterv Differential Revision: D78993226 fbshipit-source-id: 03f43c61fe9e6edaf38f895daf4f0c146df931b8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
627136ee76
commit
01eaa6db97
Vendored
+11
@@ -70,6 +70,17 @@ Object.defineProperties(global, {
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Prettier v3 uses import (cjs/mjs) file formats that jest-runtime does not
|
||||
* support. To work around this we need to bypass the jest module system by
|
||||
* using the orginal node `require` function.
|
||||
*/
|
||||
jest.mock('prettier', () => {
|
||||
// $FlowExpectedError[underconstrained-implicit-instantiation]
|
||||
const module = jest.requireActual('module');
|
||||
return module.prototype.require(require.resolve('prettier'));
|
||||
});
|
||||
|
||||
// $FlowFixMe[incompatible-call] - `./mocks/AppState` is incomplete.
|
||||
mock('m#../Libraries/AppState/AppState', 'm#./mocks/AppState');
|
||||
mock('m#../Libraries/BatchedBridge/NativeModules', 'm#./mocks/NativeModules');
|
||||
|
||||
Reference in New Issue
Block a user