Skip to content

Commit 8f3bda1

Browse files
committed
chore: remove test renderer dep
1 parent 08747ea commit 8f3bda1

File tree

9 files changed

+27
-104
lines changed

9 files changed

+27
-104
lines changed

.vscode/settings.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
{
2-
"cSpell.words": ["labelledby", "Pressable", "RNTL", "Uncapitalize", "valuenow", "valuetext"]
2+
"cSpell.words": [
3+
"labelledby",
4+
"Pressable",
5+
"redent",
6+
"RNTL",
7+
"Uncapitalize",
8+
"valuenow",
9+
"valuetext"
10+
]
311
}

package.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@
5353
},
5454
"peerDependencies": {
5555
"jest": ">=28.0.0",
56-
"react": ">=16.8.0",
57-
"react-native": ">=0.59",
58-
"react-test-renderer": ">=16.8.0"
56+
"react": ">=18.0.0",
57+
"react-native": ">=0.59"
5958
},
6059
"peerDependenciesMeta": {
6160
"jest": {
@@ -76,7 +75,6 @@
7675
"@types/jest": "^29.5.12",
7776
"@types/react": "^18.3.3",
7877
"@types/react-reconciler": "^0",
79-
"@types/react-test-renderer": "^18.3.0",
8078
"babel-jest": "^29.7.0",
8179
"del-cli": "^5.1.0",
8280
"eslint": "^8.57.0",
@@ -87,7 +85,6 @@
8785
"prettier": "^2.8.8",
8886
"react": "18.3.1",
8987
"react-native": "0.75.1",
90-
"react-test-renderer": "18.3.1",
9188
"release-it": "^17.6.0",
9289
"strip-ansi": "^6.0.1",
9390
"typescript": "^5.5.4"

src/__tests__/screen.test.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,5 @@ test('screen throws without render', () => {
5555
expect(() => screen.root).toThrow('`render` method has not been called');
5656
expect(() => screen.container).toThrow('`render` method has not been called');
5757
expect(() => screen.debug()).toThrow('`render` method has not been called');
58-
expect(() => screen.debug.shallow()).toThrow('`render` method has not been called');
5958
expect(() => screen.getByText('Mt. Everest')).toThrow('`render` method has not been called');
6059
});

src/act.ts

+2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ function getGlobalThis() {
1212
return globalThis;
1313
}
1414
/* istanbul ignore next */
15+
// eslint-disable-next-line no-restricted-globals
1516
if (typeof self !== 'undefined') {
17+
// eslint-disable-next-line no-restricted-globals
1618
return self;
1719
}
1820
/* istanbul ignore next */

src/helpers/debug-shallow.ts

-22
This file was deleted.

src/matchers/utils.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import redent from 'redent';
1111
import { isValidElement } from '../helpers/component-tree';
1212
import { defaultMapProps } from '../helpers/format-default';
1313
import { HostElement, HostNode } from '../renderer/host-element';
14-
import { getTextContent } from '../helpers/text-content';
1514

1615
class HostElementTypeError extends Error {
1716
constructor(received: unknown, matcherFn: jest.CustomMatcher, context: jest.MatcherContext) {
@@ -70,10 +69,8 @@ export function formatElement(element: HostNode | null) {
7069
return element;
7170
}
7271

72+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
7373
const { children, ...props } = element.props;
74-
const childrenToDisplay = typeof children === 'string' ? [children] : undefined;
75-
76-
const textContent = getTextContent(element);
7774

7875
return redent(
7976
prettyFormat(
@@ -83,6 +80,7 @@ export function formatElement(element: HostNode | null) {
8380
$$typeof: Symbol.for('react.test.json'),
8481
type: element.type,
8582
props: defaultMapProps(props),
83+
// TODO: Recursively format children
8684
children: element.children.filter((child) => typeof child === 'string'),
8785
},
8886
{

src/render.tsx

+4-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import act from './act';
33
import { addToCleanupQueue } from './cleanup';
44
import { getConfig } from './config';
55
import debugDeep, { DebugOptions } from './helpers/debug-deep';
6-
import debugShallow from './helpers/debug-shallow';
76
import { configureHostComponentNamesIfNeeded } from './helpers/host-component-names';
87
import { HostElement } from './renderer/host-element';
98
import { RenderResult as RendererResult } from './renderer/renderer';
@@ -66,7 +65,7 @@ function buildRenderResult(
6665
unmount,
6766
rerender: update, // alias for `update`
6867
toJSON: renderer.toJSON,
69-
debug: debug(instance, renderer),
68+
debug: debug(renderer),
7069
get root(): HostElement {
7170
return renderer.root;
7271
},
@@ -88,12 +87,9 @@ function updateWithAct(
8887
};
8988
}
9089

91-
export interface DebugFunction {
92-
(options?: DebugOptions | string): void;
93-
shallow: (message?: string) => void;
94-
}
90+
export type DebugFunction = (options?: DebugOptions | string) => void;
9591

96-
function debug(instance: HostElement, renderer: RendererResult): DebugFunction {
92+
function debug(renderer: RendererResult): DebugFunction {
9793
function debugImpl(options?: DebugOptions | string) {
9894
const { defaultDebugOptions } = getConfig();
9995
const debugOptions =
@@ -113,6 +109,6 @@ function debug(instance: HostElement, renderer: RendererResult): DebugFunction {
113109
return debugDeep(json, debugOptions);
114110
}
115111
}
116-
debugImpl.shallow = (message?: string) => debugShallow(instance, message);
112+
117113
return debugImpl;
118114
}

src/shallow.ts

-18
This file was deleted.

yarn.lock

+8-45
Original file line numberDiff line numberDiff line change
@@ -2876,7 +2876,6 @@ __metadata:
28762876
"@types/jest": "npm:^29.5.12"
28772877
"@types/react": "npm:^18.3.3"
28782878
"@types/react-reconciler": "npm:^0"
2879-
"@types/react-test-renderer": "npm:^18.3.0"
28802879
babel-jest: "npm:^29.7.0"
28812880
del-cli: "npm:^5.1.0"
28822881
eslint: "npm:^8.57.0"
@@ -2890,16 +2889,14 @@ __metadata:
28902889
react: "npm:18.3.1"
28912890
react-native: "npm:0.75.1"
28922891
react-reconciler: "npm:0.29.2"
2893-
react-test-renderer: "npm:18.3.1"
28942892
redent: "npm:^3.0.0"
28952893
release-it: "npm:^17.6.0"
28962894
strip-ansi: "npm:^6.0.1"
28972895
typescript: "npm:^5.5.4"
28982896
peerDependencies:
28992897
jest: ">=28.0.0"
2900-
react: ">=16.8.0"
2898+
react: ">=18.0.0"
29012899
react-native: ">=0.59"
2902-
react-test-renderer: ">=16.8.0"
29032900
peerDependenciesMeta:
29042901
jest:
29052902
optional: true
@@ -3060,15 +3057,6 @@ __metadata:
30603057
languageName: node
30613058
linkType: hard
30623059

3063-
"@types/react-test-renderer@npm:^18.3.0":
3064-
version: 18.3.0
3065-
resolution: "@types/react-test-renderer@npm:18.3.0"
3066-
dependencies:
3067-
"@types/react": "npm:*"
3068-
checksum: 10c0/3c9748be52e8e659e7adf91dea6939486463264e6f633bf21c4cb116de18af7bef0595568a1e588160420b2f65289473075dda1cb417c2875df8cf7a09f5d913
3069-
languageName: node
3070-
linkType: hard
3071-
30723060
"@types/react@npm:*, @types/react@npm:^18.3.3":
30733061
version: 18.3.3
30743062
resolution: "@types/react@npm:18.3.3"
@@ -10018,13 +10006,6 @@ __metadata:
1001810006
languageName: node
1001910007
linkType: hard
1002010008

10021-
"react-is@npm:^16.12.0 || ^17.0.0 || ^18.0.0, react-is@npm:^18.0.0, react-is@npm:^18.3.1":
10022-
version: 18.3.1
10023-
resolution: "react-is@npm:18.3.1"
10024-
checksum: 10c0/f2f1e60010c683479e74c63f96b09fb41603527cd131a9959e2aee1e5a8b0caf270b365e5ca77d4a6b18aae659b60a86150bb3979073528877029b35aecd2072
10025-
languageName: node
10026-
linkType: hard
10027-
1002810009
"react-is@npm:^16.13.1":
1002910010
version: 16.13.1
1003010011
resolution: "react-is@npm:16.13.1"
@@ -10039,6 +10020,13 @@ __metadata:
1003910020
languageName: node
1004010021
linkType: hard
1004110022

10023+
"react-is@npm:^18.0.0":
10024+
version: 18.3.1
10025+
resolution: "react-is@npm:18.3.1"
10026+
checksum: 10c0/f2f1e60010c683479e74c63f96b09fb41603527cd131a9959e2aee1e5a8b0caf270b365e5ca77d4a6b18aae659b60a86150bb3979073528877029b35aecd2072
10027+
languageName: node
10028+
linkType: hard
10029+
1004210030
"react-native@npm:0.75.1":
1004310031
version: 0.75.1
1004410032
resolution: "react-native@npm:0.75.1"
@@ -10112,31 +10100,6 @@ __metadata:
1011210100
languageName: node
1011310101
linkType: hard
1011410102

10115-
"react-shallow-renderer@npm:^16.15.0":
10116-
version: 16.15.0
10117-
resolution: "react-shallow-renderer@npm:16.15.0"
10118-
dependencies:
10119-
object-assign: "npm:^4.1.1"
10120-
react-is: "npm:^16.12.0 || ^17.0.0 || ^18.0.0"
10121-
peerDependencies:
10122-
react: ^16.0.0 || ^17.0.0 || ^18.0.0
10123-
checksum: 10c0/c194d741792e86043a4ae272f7353c1cb9412bc649945c4220c6a101a6ea5410cceb3d65d5a4d750f11a24f7426e8eec7977e8a4e3ad5d3ee235ca2b18166fa8
10124-
languageName: node
10125-
linkType: hard
10126-
10127-
"react-test-renderer@npm:18.3.1":
10128-
version: 18.3.1
10129-
resolution: "react-test-renderer@npm:18.3.1"
10130-
dependencies:
10131-
react-is: "npm:^18.3.1"
10132-
react-shallow-renderer: "npm:^16.15.0"
10133-
scheduler: "npm:^0.23.2"
10134-
peerDependencies:
10135-
react: ^18.3.1
10136-
checksum: 10c0/c633558ef9af33bc68f0c4dbb5163a004c4fb9eade7bd0a7cfc0355fb367f36bd9d96533c90b7e85a146be6c525113a15f58683d269e0177ad77e2b04d4fe51c
10137-
languageName: node
10138-
linkType: hard
10139-
1014010103
"react@npm:18.3.1":
1014110104
version: 18.3.1
1014210105
resolution: "react@npm:18.3.1"

0 commit comments

Comments
 (0)