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/49340 This tool enables checking the boundary between JavaScript and Native for backwards incompatible changes to protect against crashes. This is useful for: - Local Development - Over the Air updates on platforms that support it - Theoretically: Server Components with React Native Check out the Readme for more information Changelog: [General][Added] Open Sourcing React Native's Compatibility Check Reviewed By: panagosg7 Differential Revision: D69476742 fbshipit-source-id: 8af6039839c5475c1258fa82d9750a9320cf0751
66 lines
1.6 KiB
JavaScript
66 lines
1.6 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
|
|
* @format
|
|
* @oncall react_native
|
|
*/
|
|
|
|
import {formatDiffSet} from '../ErrorFormatting.js';
|
|
import {buildSchemaDiff, summarizeDiffSet} from '../VersionDiffing.js';
|
|
import {incompatibleChanges, okayChanges} from './ErrorFormattingTests.js';
|
|
import {getTestSchema} from './utilities/getTestSchema.js';
|
|
|
|
describe('codegen formattedSummarizeDiffSet', () => {
|
|
okayChanges.forEach(([after, before]) => {
|
|
it(`allows a diff from ${before} to ${after}`, () => {
|
|
const beforeObj = getTestSchema(
|
|
__dirname,
|
|
'__fixtures__',
|
|
before + '.js.flow',
|
|
);
|
|
|
|
const afterObj = getTestSchema(
|
|
__dirname,
|
|
'__fixtures__',
|
|
after + '.js.flow',
|
|
);
|
|
|
|
const result = formatDiffSet(
|
|
summarizeDiffSet(buildSchemaDiff(afterObj, beforeObj)),
|
|
);
|
|
|
|
expect(result.status).toEqual('ok');
|
|
|
|
expect(result).toMatchSnapshot();
|
|
});
|
|
});
|
|
|
|
incompatibleChanges.forEach(([after, before]) => {
|
|
it(`reports a diff from ${before} to ${after}`, () => {
|
|
const beforeObj = getTestSchema(
|
|
__dirname,
|
|
'__fixtures__',
|
|
before + '.js.flow',
|
|
);
|
|
|
|
const afterObj = getTestSchema(
|
|
__dirname,
|
|
'__fixtures__',
|
|
after + '.js.flow',
|
|
);
|
|
|
|
const result = formatDiffSet(
|
|
summarizeDiffSet(buildSchemaDiff(afterObj, beforeObj)),
|
|
);
|
|
|
|
expect(result.status).toEqual('incompatible');
|
|
|
|
expect(result).toMatchSnapshot();
|
|
});
|
|
});
|
|
});
|