Files
react-native/packages/react-native-compatibility-check/src/__tests__/ErrorFormatting-test.js
T
Eli White 60e3921f9c Initial Open Sourcing of React Native Compatibility Check (#49340)
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
2025-02-12 08:24:13 -08:00

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();
});
});
});