Skip to content

Commit 20fcb18

Browse files
committed
[v12] refactor: enable all breaking changes (#1313)
* chore: enable all breaking changes * fix: ci issues * chore: fix lint * chore: cleanup * chore: add migration guide * chore: update docs * chore: docs tweaks * chore: docs tweaks * chore: remove useBreakingChanges config flag * refactor: code review changes * docs: tweaks
1 parent 0201182 commit 20fcb18

21 files changed

+121
-1909
lines changed

src/__tests__/__snapshots__/render.breaking.test.tsx.snap

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/__tests__/config.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
} from '../config';
77

88
test('getConfig() returns existing configuration', () => {
9-
expect(getConfig().useBreakingChanges).toEqual(false);
109
expect(getConfig().asyncUtilTimeout).toEqual(1000);
1110
expect(getConfig().defaultIncludeHiddenElements).toEqual(true);
1211
});
@@ -18,7 +17,6 @@ test('configure() overrides existing config values', () => {
1817
asyncUtilTimeout: 5000,
1918
defaultDebugOptions: { message: 'debug message' },
2019
defaultIncludeHiddenElements: true,
21-
useBreakingChanges: false,
2220
});
2321
});
2422

@@ -37,12 +35,12 @@ test('resetToDefaults() resets config to defaults', () => {
3735

3836
test('resetToDefaults() resets internal config to defaults', () => {
3937
configureInternal({
40-
useBreakingChanges: true,
38+
hostComponentNames: { text: 'A', textInput: 'A' },
4139
});
42-
expect(getConfig().useBreakingChanges).toEqual(true);
40+
expect(getConfig().hostComponentNames).toEqual({ text: 'A', textInput: 'A' });
4341

4442
resetToDefaults();
45-
expect(getConfig().useBreakingChanges).toEqual(false);
43+
expect(getConfig().hostComponentNames).toBe(undefined);
4644
});
4745

4846
test('configure handles alias option defaultHidden', () => {

src/__tests__/render.breaking.test.tsx

Lines changed: 0 additions & 247 deletions
This file was deleted.

src/__tests__/render.test.tsx

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
/* eslint-disable no-console */
22
import * as React from 'react';
3-
import { View, Text, TextInput, Pressable, SafeAreaView } from 'react-native';
4-
import { render, fireEvent, RenderAPI } from '..';
5-
6-
beforeEach(() => {
7-
jest.spyOn(console, 'warn').mockImplementation(() => {});
8-
});
3+
import { View, Text, TextInput, Pressable } from 'react-native';
4+
import { render, screen, fireEvent, RenderAPI } from '..';
95

106
const PLACEHOLDER_FRESHNESS = 'Add custom freshness';
117
const PLACEHOLDER_CHEF = 'Who inspected freshness?';
@@ -154,7 +150,6 @@ test('unmount should handle cleanup functions', () => {
154150

155151
test('toJSON renders host output', () => {
156152
const { toJSON } = render(<MyButton>press me</MyButton>);
157-
158153
expect(toJSON()).toMatchSnapshot();
159154
});
160155

@@ -224,31 +219,19 @@ test('returns composite UNSAFE_root', () => {
224219
expect(UNSAFE_root.props.testID).toBe('inner');
225220
});
226221

227-
test('returns container', () => {
228-
const { container } = render(<View testID="inner" />);
222+
test('container displays deprecation', () => {
223+
const view = render(<View testID="inner" />);
229224

230-
expect(container).toBeDefined();
231-
// `View` composite component is returned. This behavior will break if we
232-
// start returning only host components.
233-
expect(container.type).toBe(View);
234-
expect(container.props.testID).toBe('inner');
235-
});
236-
237-
test('returns wrapper component as container', () => {
238-
type WrapperComponentProps = { children: React.ReactNode };
239-
const WrapperComponent = ({ children }: WrapperComponentProps) => (
240-
<SafeAreaView testID="wrapper">{children}</SafeAreaView>
241-
);
225+
expect(() => view.container).toThrowErrorMatchingInlineSnapshot(`
226+
"'container' property has been renamed to 'UNSAFE_root'.
242227
243-
const { container } = render(<View testID="inner" />, {
244-
wrapper: WrapperComponent,
245-
});
228+
Consider using 'root' property which returns root host element."
229+
`);
230+
expect(() => screen.container).toThrowErrorMatchingInlineSnapshot(`
231+
"'container' property has been renamed to 'UNSAFE_root'.
246232
247-
expect(container).toBeDefined();
248-
// `WrapperComponent` composite component is returned with no testID passed to
249-
// it. This behavior will break if we start returning only host components.
250-
expect(container.type).toBe(WrapperComponent);
251-
expect(container.props.testID).not.toBeDefined();
233+
Consider using 'root' property which returns root host element."
234+
`);
252235
});
253236

254237
test('RenderAPI type', () => {

src/config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,11 @@ export type HostComponentNames = {
2626
};
2727

2828
export type InternalConfig = Config & {
29-
/** Whether to use breaking changes intended for next major version release. */
30-
useBreakingChanges: boolean;
31-
3229
/** Names for key React Native host components. */
3330
hostComponentNames?: HostComponentNames;
3431
};
3532

3633
const defaultConfig: InternalConfig = {
37-
useBreakingChanges: false,
3834
asyncUtilTimeout: 1000,
3935
defaultIncludeHiddenElements: true,
4036
};

0 commit comments

Comments
 (0)