Skip to content

Commit 08e1f75

Browse files
committed
remove legacy debug variant
1 parent 6aaba3c commit 08e1f75

File tree

4 files changed

+38
-61
lines changed

4 files changed

+38
-61
lines changed

src/__tests__/render-debug.test.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,12 @@ test('debug', () => {
9494

9595
screen.debug();
9696
screen.debug({ message: 'another custom message' });
97-
screen.debug('my custom message');
9897
screen.debug({ mapProps: null });
9998

10099
const mockCalls = jest.mocked(logger.info).mock.calls;
101100
expect(mockCalls[0][0]).toMatchSnapshot();
102101
expect(`${mockCalls[1][0]}\n${mockCalls[1][1]}`).toMatchSnapshot('Option message');
103-
expect(`${mockCalls[2][0]}\n${mockCalls[2][1]}`).toMatchSnapshot('Legacy message');
104-
expect(`${mockCalls[3][0]}\n${mockCalls[3][1]}`).toMatchSnapshot('All Props');
105-
106-
const mockWarnCalls = jest.mocked(logger.warn).mock.calls;
107-
expect(mockWarnCalls[0]).toMatchInlineSnapshot(`
108-
[
109-
"Using debug("message") is deprecated and will be removed in future release, please use debug({ message: "message" }) instead.",
110-
]
111-
`);
102+
expect(`${mockCalls[2][0]}\n${mockCalls[2][1]}`).toMatchSnapshot('All Props');
112103
});
113104

114105
test('debug changing component', () => {

src/helpers/debug.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ export type DebugOptions = {
1212
*/
1313
export function debug(
1414
instance: ReactTestRendererJSON | ReactTestRendererJSON[],
15-
options: DebugOptions | string = {},
15+
{ message, ...formatOptions }: DebugOptions = {},
1616
) {
17-
const { message, ...formatOptions } =
18-
typeof options === 'string' ? { message: options } : options;
19-
2017
if (message) {
2118
logger.info(`${message}\n\n`, formatJson(instance, formatOptions));
2219
} else {

src/render.tsx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { getConfig } from './config';
1010
import { getHostSelves } from './helpers/component-tree';
1111
import type { DebugOptions } from './helpers/debug';
1212
import { debug } from './helpers/debug';
13-
import { logger } from './helpers/logger';
1413
import { validateStringsRenderedWithinText } from './helpers/string-validation';
1514
import { renderWithAct } from './render-act';
1615
import { setRenderResult } from './screen';
@@ -150,22 +149,12 @@ function updateWithAct(
150149
};
151150
}
152151

153-
export type DebugFunction = (options?: DebugOptions | string) => void;
152+
export type DebugFunction = (options?: DebugOptions) => void;
154153

155-
function makeDebug(instance: ReactTestInstance, renderer: ReactTestRenderer): DebugFunction {
156-
function debugImpl(options?: DebugOptions | string) {
154+
function makeDebug(_instance: ReactTestInstance, renderer: ReactTestRenderer): DebugFunction {
155+
function debugImpl(options?: DebugOptions) {
157156
const { defaultDebugOptions } = getConfig();
158-
const debugOptions =
159-
typeof options === 'string'
160-
? { ...defaultDebugOptions, message: options }
161-
: { ...defaultDebugOptions, ...options };
162-
163-
if (typeof options === 'string') {
164-
logger.warn(
165-
'Using debug("message") is deprecated and will be removed in future release, please use debug({ message: "message" }) instead.',
166-
);
167-
}
168-
157+
const debugOptions = { ...defaultDebugOptions, ...options };
169158
const json = renderer.toJSON();
170159
if (json) {
171160
return debug(json, debugOptions);

typings/index.flow.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ declare type A11yRole =
5555

5656
declare type A11yState = {|
5757
disabled?: boolean,
58-
selected ?: boolean,
59-
checked ?: boolean | 'mixed',
60-
busy ?: boolean,
61-
expanded ?: boolean,
58+
selected?: boolean,
59+
checked?: boolean | 'mixed',
60+
busy?: boolean,
61+
expanded?: boolean,
6262
|};
6363

6464
declare type A11yValue = {
@@ -86,12 +86,12 @@ interface ByTextQueries {
8686
findByText: (
8787
text: TextMatch,
8888
queryOptions?: ByTextOptions,
89-
waitForOptions?: WaitForOptions
89+
waitForOptions?: WaitForOptions,
9090
) => FindReturn;
9191
findAllByText: (
9292
text: TextMatch,
9393
queryOptions?: ByTextOptions,
94-
waitForOptions?: WaitForOptions
94+
waitForOptions?: WaitForOptions,
9595
) => FindAllReturn;
9696
}
9797

@@ -105,12 +105,12 @@ interface ByTestIdQueries {
105105
findByTestId: (
106106
testID: TextMatch,
107107
queryOptions?: ByTestIdOptions,
108-
waitForOptions?: WaitForOptions
108+
waitForOptions?: WaitForOptions,
109109
) => FindReturn;
110110
findAllByTestId: (
111111
testID: TextMatch,
112112
queryOptions?: ByTestIdOptions,
113-
waitForOptions?: WaitForOptions
113+
waitForOptions?: WaitForOptions,
114114
) => FindAllReturn;
115115
}
116116

@@ -120,25 +120,25 @@ interface ByDisplayValueQueries {
120120
getByDisplayValue: (value: TextMatch, options?: ByDisplayValueOptions) => ReactTestInstance;
121121
getAllByDisplayValue: (
122122
value: TextMatch,
123-
options?: ByDisplayValueOptions
123+
options?: ByDisplayValueOptions,
124124
) => Array<ReactTestInstance>;
125125
queryByDisplayValue: (
126126
value: TextMatch,
127-
options?: ByDisplayValueOptions
127+
options?: ByDisplayValueOptions,
128128
) => ReactTestInstance | null;
129129
queryAllByDisplayValue: (
130130
value: TextMatch,
131-
options?: ByDisplayValueOptions
131+
options?: ByDisplayValueOptions,
132132
) => Array<ReactTestInstance> | [];
133133
findByDisplayValue: (
134134
value: TextMatch,
135135
queryOptions?: ByDisplayValueOptions,
136-
waitForOptions?: WaitForOptions
136+
waitForOptions?: WaitForOptions,
137137
) => FindReturn;
138138
findAllByDisplayValue: (
139139
value: TextMatch,
140140
queryOptions?: ByDisplayValueOptions,
141-
waitForOptions?: WaitForOptions
141+
waitForOptions?: WaitForOptions,
142142
) => FindAllReturn;
143143
}
144144

@@ -147,29 +147,29 @@ type ByPlaceholderTextOptions = CommonQueryOptions & TextMatchOptions;
147147
interface ByPlaceholderTextQueries {
148148
getByPlaceholderText: (
149149
placeholder: TextMatch,
150-
options?: ByPlaceholderTextOptions
150+
options?: ByPlaceholderTextOptions,
151151
) => ReactTestInstance;
152152
getAllByPlaceholderText: (
153153
placeholder: TextMatch,
154-
options?: ByPlaceholderTextOptions
154+
options?: ByPlaceholderTextOptions,
155155
) => Array<ReactTestInstance>;
156156
queryByPlaceholderText: (
157157
placeholder: TextMatch,
158-
options?: ByPlaceholderTextOptions
158+
options?: ByPlaceholderTextOptions,
159159
) => ReactTestInstance | null;
160160
queryAllByPlaceholderText: (
161161
placeholder: TextMatch,
162-
options?: ByPlaceholderTextOptions
162+
options?: ByPlaceholderTextOptions,
163163
) => Array<ReactTestInstance> | [];
164164
findByPlaceholderText: (
165165
placeholder: TextMatch,
166166
queryOptions?: ByPlaceholderTextOptions,
167-
waitForOptions?: WaitForOptions
167+
waitForOptions?: WaitForOptions,
168168
) => FindReturn;
169169
findAllByPlaceholderText: (
170170
placeholder: TextMatch,
171171
queryOptions?: ByPlaceholderTextOptions,
172-
waitForOptions?: WaitForOptions
172+
waitForOptions?: WaitForOptions,
173173
) => FindAllReturn;
174174
}
175175

@@ -205,12 +205,12 @@ interface A11yAPI {
205205
findByLabelText: (
206206
matcher: TextMatch,
207207
queryOptions?: ByLabelTextOptions,
208-
waitForOptions?: WaitForOptions
208+
waitForOptions?: WaitForOptions,
209209
) => FindReturn;
210210
findAllByLabelText: (
211211
matcher: TextMatch,
212212
queryOptions?: ByLabelTextOptions,
213-
waitForOptions?: WaitForOptions
213+
waitForOptions?: WaitForOptions,
214214
) => FindAllReturn;
215215

216216
// Hint
@@ -225,22 +225,22 @@ interface A11yAPI {
225225
findByA11yHint: (
226226
matcher: TextMatch,
227227
queryOptions?: ByHintTextOptions,
228-
waitForOptions?: WaitForOptions
228+
waitForOptions?: WaitForOptions,
229229
) => FindReturn;
230230
findByHintText: (
231231
matcher: TextMatch,
232232
queryOptions?: ByHintTextOptions,
233-
waitForOptions?: WaitForOptions
233+
waitForOptions?: WaitForOptions,
234234
) => FindReturn;
235235
findAllByA11yHint: (
236236
matcher: TextMatch,
237237
queryOptions?: ByHintTextOptions,
238-
waitForOptions?: WaitForOptions
238+
waitForOptions?: WaitForOptions,
239239
) => FindAllReturn;
240240
findAllByHintText: (
241241
matcher: TextMatch,
242242
queryOptions?: ByHintTextOptions,
243-
waitForOptions?: WaitForOptions
243+
waitForOptions?: WaitForOptions,
244244
) => FindAllReturn;
245245

246246
// Role
@@ -251,12 +251,12 @@ interface A11yAPI {
251251
findByRole: (
252252
matcher: A11yRole | RegExp,
253253
queryOptions?: ByRoleOptions,
254-
waitForOptions?: WaitForOptions
254+
waitForOptions?: WaitForOptions,
255255
) => FindReturn;
256256
findAllByRole: (
257257
matcher: A11yRole | RegExp,
258258
queryOptions?: ByRoleOptions,
259-
waitForOptions?: WaitForOptions
259+
waitForOptions?: WaitForOptions,
260260
) => FindAllReturn;
261261
}
262262

@@ -266,7 +266,7 @@ interface Thenable {
266266

267267
type MapPropsFunction = (
268268
props: { [string]: mixed },
269-
node: ReactTestRendererJSON
269+
node: ReactTestRendererJSON,
270270
) => { [string]: mixed };
271271

272272
type DebugOptions = {
@@ -275,7 +275,7 @@ type DebugOptions = {
275275
};
276276

277277
type Debug = {
278-
(options?: DebugOptions | string): void,
278+
(options?: DebugOptions): void,
279279
};
280280

281281
type Queries = ByTextQueries &
@@ -322,7 +322,7 @@ declare module '@testing-library/react-native' {
322322

323323
declare export var render: (
324324
component: React.Element<any>,
325-
options?: RenderOptions
325+
options?: RenderOptions,
326326
) => RenderResult;
327327

328328
declare export var screen: RenderResult;
@@ -334,7 +334,7 @@ declare module '@testing-library/react-native' {
334334

335335
declare type WaitForElementToBeRemovedFunction = <T = any>(
336336
expectation: () => T,
337-
options?: WaitForOptions
337+
options?: WaitForOptions,
338338
) => Promise<T>;
339339

340340
declare export var waitForElementToBeRemoved: WaitForElementToBeRemovedFunction;
@@ -375,7 +375,7 @@ declare module '@testing-library/react-native' {
375375

376376
declare type RenderHookFunction = <Result, Props>(
377377
renderCallback: (props: Props) => Result,
378-
options?: RenderHookOptions<Props>
378+
options?: RenderHookOptions<Props>,
379379
) => RenderHookResult<Result, Props>;
380380

381381
declare export var renderHook: RenderHookFunction;

0 commit comments

Comments
 (0)