Use Meta-specific renderers when running tests in Meta infra (#47705)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47705

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D66094272

fbshipit-source-id: 25c0bc2d9e68ed1f4ede9dc5f0470a530b5db7d0
This commit is contained in:
Rubén Norte 2024-11-19 05:53:26 -08:00 committed by Facebook GitHub Bot
parent 13bc4a2a43
commit 4da6ed5caf
4 changed files with 56 additions and 5 deletions

View File

@ -0,0 +1,30 @@
/**
* 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.
*
* @format
*/
'use strict';
const crypto = require('crypto');
const fs = require('fs');
module.exports = {
getHasteName(filePath) {
if (filePath.endsWith('ReactNativeInternalFeatureFlags.js')) {
return 'ReactNativeInternalFeatureFlags';
}
return null;
},
getCacheKey() {
return crypto
.createHash('sha1')
.update(fs.readFileSync(__filename))
.digest('hex');
},
};

View File

@ -23,18 +23,27 @@ const config = {
update: () => {},
},
resolver: {
blockList: null,
sourceExts: [...rnTesterConfig.resolver.sourceExts, 'fb.js'],
blockList: /\/RendererProxy\.fb\.js$/, // Disable dependency injection for the renderer
disableHierarchicalLookup: !!process.env.JS_DIR,
sourceExts: ['fb.js', ...rnTesterConfig.resolver.sourceExts],
nodeModulesPaths: process.env.JS_DIR
? [path.join(process.env.JS_DIR, 'public', 'node_modules')]
: [],
hasteImplModulePath: path.resolve(__dirname, 'hasteImpl.js'),
},
transformer: {
// We need to wrap the default transformer so we can run it from source
// using babel-register.
babelTransformerPath: path.resolve(__dirname, 'metro-babel-transformer.js'),
},
watchFolders: process.env.JS_DIR ? [process.env.JS_DIR] : [],
watchFolders: process.env.JS_DIR
? [
path.join(process.env.JS_DIR, 'RKJSModules', 'vendor', 'react'),
path.join(process.env.JS_DIR, 'tools', 'metro'),
path.join(process.env.JS_DIR, 'node_modules'),
path.join(process.env.JS_DIR, 'public', 'node_modules'),
]
: [],
};
module.exports = mergeConfig(rnTesterConfig, config);

View File

@ -92,8 +92,8 @@ module.exports = async function runTest(
const setupModulePath = path.resolve(__dirname, '../runtime/setup.js');
const entrypointContents = entrypointTemplate({
testPath: `.${path.sep}${path.relative(BUILD_OUTPUT_PATH, testPath)}`,
setupModulePath: `.${path.sep}${path.relative(BUILD_OUTPUT_PATH, setupModulePath)}`,
testPath: `${path.relative(BUILD_OUTPUT_PATH, testPath)}`,
setupModulePath: `${path.relative(BUILD_OUTPUT_PATH, setupModulePath)}`,
});
const entrypointPath = path.join(

View File

@ -0,0 +1,12 @@
/**
* 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-local
* @format
* @oncall react_native
*/
// Left intentionally empty. All flags are assumed to be false.