mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48029 Changelog: [Internal] Adding snapshot support for rendered output only for now. This will only work if snapshot is created beforehand by hand. # Next steps * Create snapshot when no prior snapshot is available * Pass and update if instructed Reviewed By: christophpurrer Differential Revision: D66601387 fbshipit-source-id: fe528cded43c5ba36d314bd9af8e3fb84b98ac3e
56 lines
1.4 KiB
JavaScript
56 lines
1.4 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-local
|
|
* @format
|
|
* @oncall react_native
|
|
*/
|
|
|
|
import type {SnapshotConfig} from '../runtime/snapshotContext';
|
|
import type {FantomTestConfigJsOnlyFeatureFlags} from './getFantomTestConfig';
|
|
|
|
module.exports = function entrypointTemplate({
|
|
testPath,
|
|
setupModulePath,
|
|
featureFlagsModulePath,
|
|
featureFlags,
|
|
snapshotConfig,
|
|
}: {
|
|
testPath: string,
|
|
setupModulePath: string,
|
|
featureFlagsModulePath: string,
|
|
featureFlags: FantomTestConfigJsOnlyFeatureFlags,
|
|
snapshotConfig: SnapshotConfig,
|
|
}): string {
|
|
return `/**
|
|
* 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.
|
|
*
|
|
* ${'@'}generated
|
|
* @noformat
|
|
* @noflow
|
|
* @oncall react_native
|
|
*/
|
|
|
|
import {registerTest} from '${setupModulePath}';
|
|
${
|
|
Object.keys(featureFlags).length > 0
|
|
? `import * as ReactNativeFeatureFlags from '${featureFlagsModulePath}';
|
|
|
|
ReactNativeFeatureFlags.override({
|
|
${Object.entries(featureFlags)
|
|
.map(([name, value]) => ` ${name}: () => ${JSON.stringify(value)},`)
|
|
.join('\n')}
|
|
});`
|
|
: ''
|
|
}
|
|
|
|
registerTest(() => require('${testPath}'), ${JSON.stringify(snapshotConfig)});
|
|
`;
|
|
};
|