From d563857f2ba6cc3132e7371e333d7e3d8d127df2 Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Mon, 18 May 2020 12:34:05 +0200 Subject: [PATCH 1/7] Change argument to options object --- .../{waitForElement.test.js => waitFor.test.js} | 8 +++++--- src/helpers/a11yAPI.js | 2 +- src/helpers/findByAPI.js | 14 +++----------- src/helpers/makeQuery.js | 16 ++++------------ src/index.js | 2 +- src/{waitForElement.js => waitFor.js} | 15 +++++++++++++-- 6 files changed, 27 insertions(+), 30 deletions(-) rename src/__tests__/{waitForElement.test.js => waitFor.test.js} (88%) rename src/{waitForElement.js => waitFor.js} (67%) diff --git a/src/__tests__/waitForElement.test.js b/src/__tests__/waitFor.test.js similarity index 88% rename from src/__tests__/waitForElement.test.js rename to src/__tests__/waitFor.test.js index 8867a4a5e..a8844021a 100644 --- a/src/__tests__/waitForElement.test.js +++ b/src/__tests__/waitFor.test.js @@ -52,7 +52,9 @@ test('waits for element until timeout is met', async () => { fireEvent.press(getByName('TouchableOpacity')); - await expect(waitForElement(() => getByText('Fresh'), 100)).rejects.toThrow(); + await expect( + waitForElement(() => getByText('Fresh'), { timeout: 100 }) + ).rejects.toThrow(); }); test('waits for element with custom interval', async () => { @@ -61,7 +63,7 @@ test('waits for element with custom interval', async () => { }); try { - await waitForElement(() => mockFn(), 400, 200); + await waitForElement(() => mockFn(), { timeout: 400, interval: 200 }); } catch (e) { // suppress } @@ -77,7 +79,7 @@ test('works with fake timers', async () => { }); try { - waitForElement(() => mockFn(), 400, 200); + waitForElement(() => mockFn(), { timeout: 400, interval: 200 }); } catch (e) { // suppress } diff --git a/src/helpers/a11yAPI.js b/src/helpers/a11yAPI.js index 40598b9b5..ac62221ea 100644 --- a/src/helpers/a11yAPI.js +++ b/src/helpers/a11yAPI.js @@ -1,6 +1,6 @@ // @flow import type { A11yRole, A11yStates, A11yState, A11yValue } from '../types.flow'; -import type { WaitForOptions } from './findByAPI'; +import type { WaitForOptions } from '../waitFor.js'; import makeQuery from './makeQuery'; type GetReturn = ReactTestInstance; diff --git a/src/helpers/findByAPI.js b/src/helpers/findByAPI.js index 7b773979b..8a2c2901a 100644 --- a/src/helpers/findByAPI.js +++ b/src/helpers/findByAPI.js @@ -1,5 +1,6 @@ // @flow -import waitForElement from '../waitForElement'; +import waitForElement from '../waitFor'; +import type { WaitForOptions } from '../waitFor'; import { fixedGetByTestId, getAllByTestId, @@ -11,22 +12,13 @@ import { getAllByDisplayValue, } from './getByAPI'; -export type WaitForOptions = { - timeout?: number, - interval?: number, -}; - const makeFindQuery = ( instance: ReactTestInstance, getQuery: (instance: ReactTestInstance) => (text: Text) => Result, text: Text, waitForOptions: WaitForOptions ): Promise => - waitForElement( - () => getQuery(instance)(text), - waitForOptions.timeout, - waitForOptions.interval - ); + waitForElement(() => getQuery(instance)(text), waitForOptions); export const findByTestId = (instance: ReactTestInstance) => ( testId: string, diff --git a/src/helpers/makeQuery.js b/src/helpers/makeQuery.js index facda0fc3..2aec42c7d 100644 --- a/src/helpers/makeQuery.js +++ b/src/helpers/makeQuery.js @@ -1,11 +1,11 @@ // @flow -import waitForElement from '../waitForElement'; +import waitForElement from '../waitFor'; +import type { WaitForOptions } from '../waitFor'; import { ErrorWithStack, prepareErrorMessage, createQueryByError, } from './errors'; -import type { WaitForOptions } from './findByAPI'; function isNodeValid(node: ReactTestInstance) { return typeof node.type === 'string'; @@ -70,19 +70,11 @@ const makeQuery = ( }; const findBy = (matcher: M, waitForOptions?: WaitForOptions) => { - return waitForElement( - () => getBy(matcher), - waitForOptions?.timeout, - waitForOptions?.interval - ); + return waitForElement(() => getBy(matcher), waitForOptions); }; const findAllBy = (matcher: M, waitForOptions?: WaitForOptions) => { - return waitForElement( - () => getAllBy(matcher), - waitForOptions?.timeout, - waitForOptions?.interval - ); + return waitForElement(() => getAllBy(matcher), waitForOptions); }; return { diff --git a/src/index.js b/src/index.js index 2e7ac9f20..945488dc7 100644 --- a/src/index.js +++ b/src/index.js @@ -6,7 +6,7 @@ import fireEvent from './fireEvent'; import flushMicrotasksQueue from './flushMicrotasksQueue'; import render from './render'; import shallow from './shallow'; -import waitForElement from './waitForElement'; +import waitForElement from './waitFor'; import within from './within'; export { act }; diff --git a/src/waitForElement.js b/src/waitFor.js similarity index 67% rename from src/waitForElement.js rename to src/waitFor.js index 5072a99b9..7d4b8d55e 100644 --- a/src/waitForElement.js +++ b/src/waitFor.js @@ -1,10 +1,21 @@ // @flow + +const DEFAULT_TIMEOUT = 4500; +const DEFAULT_INTERVAL = 50; + +export type WaitForOptions = { + timeout?: number, + interval?: number, +}; + export default function waitForElement( expectation: () => T, - timeout: number = 4500, - interval: number = 50 + options?: WaitForOptions ): Promise { + const timeout = options?.timeout ?? DEFAULT_TIMEOUT; + const interval = options?.interval ?? DEFAULT_INTERVAL; const startTime = Date.now(); + return new Promise((resolve, reject) => { const rejectOrRerun = (error) => { if (Date.now() - startTime >= timeout) { From 3766092105887473884c62e5a20b03e1d45c6ebe Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Mon, 18 May 2020 14:10:59 +0200 Subject: [PATCH 2/7] Renamed `waitForElement` to `waitFor` --- README.md | 2 +- src/__tests__/waitFor.test.js | 10 +++++----- src/helpers/findByAPI.js | 5 ++--- src/helpers/makeQuery.js | 6 +++--- src/index.js | 4 ++-- src/waitFor.js | 2 +- typings/__tests__/index.test.tsx | 13 +++++++------ typings/index.d.ts | 7 +++---- website/docs/API.md | 15 +++++++-------- website/docs/Queries.md | 5 ++--- 10 files changed, 33 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 2bf662c11..a5be958c0 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ The [public API](https://callstack.github.io/react-native-testing-library/docs/a - [`render`](https://callstack.github.io/react-native-testing-library/docs/api#render) – deeply renders given React element and returns helpers to query the output components. - [`fireEvent`](https://callstack.github.io/react-native-testing-library/docs/api#fireevent) - invokes named event handler on the element. -- [`waitForElement`](https://callstack.github.io/react-native-testing-library/docs/api#waitforelement) - waits for non-deterministic periods of time until your element appears or times out. +- [`waitFor`](https://callstack.github.io/react-native-testing-library/docs/api#waitfor) - waits for non-deterministic periods of time until your element appears or times out. - [`within`](https://callstack.github.io/react-native-testing-library/docs/api#within) - creates a queries object scoped for given element. - [`flushMicrotasksQueue`](https://callstack.github.io/react-native-testing-library/docs/api#flushmicrotasksqueue) - waits for microtasks queue to flush. diff --git a/src/__tests__/waitFor.test.js b/src/__tests__/waitFor.test.js index a8844021a..b05f1fe93 100644 --- a/src/__tests__/waitFor.test.js +++ b/src/__tests__/waitFor.test.js @@ -1,7 +1,7 @@ // @flow import React from 'react'; import { View, Text, TouchableOpacity } from 'react-native'; -import { render, fireEvent, waitForElement } from '..'; +import { render, fireEvent, waitFor } from '..'; class Banana extends React.Component { changeFresh = () => { @@ -42,7 +42,7 @@ test('waits for element until it stops throwing', async () => { expect(queryByText('Fresh')).toBeNull(); - const freshBananaText = await waitForElement(() => getByText('Fresh')); + const freshBananaText = await waitFor(() => getByText('Fresh')); expect(freshBananaText.props.children).toBe('Fresh'); }); @@ -53,7 +53,7 @@ test('waits for element until timeout is met', async () => { fireEvent.press(getByName('TouchableOpacity')); await expect( - waitForElement(() => getByText('Fresh'), { timeout: 100 }) + waitFor(() => getByText('Fresh'), { timeout: 100 }) ).rejects.toThrow(); }); @@ -63,7 +63,7 @@ test('waits for element with custom interval', async () => { }); try { - await waitForElement(() => mockFn(), { timeout: 400, interval: 200 }); + await waitFor(() => mockFn(), { timeout: 400, interval: 200 }); } catch (e) { // suppress } @@ -79,7 +79,7 @@ test('works with fake timers', async () => { }); try { - waitForElement(() => mockFn(), { timeout: 400, interval: 200 }); + waitFor(() => mockFn(), { timeout: 400, interval: 200 }); } catch (e) { // suppress } diff --git a/src/helpers/findByAPI.js b/src/helpers/findByAPI.js index 8a2c2901a..caa4ddbf2 100644 --- a/src/helpers/findByAPI.js +++ b/src/helpers/findByAPI.js @@ -1,5 +1,5 @@ // @flow -import waitForElement from '../waitFor'; +import waitFor from '../waitFor'; import type { WaitForOptions } from '../waitFor'; import { fixedGetByTestId, @@ -17,8 +17,7 @@ const makeFindQuery = ( getQuery: (instance: ReactTestInstance) => (text: Text) => Result, text: Text, waitForOptions: WaitForOptions -): Promise => - waitForElement(() => getQuery(instance)(text), waitForOptions); +): Promise => waitFor(() => getQuery(instance)(text), waitForOptions); export const findByTestId = (instance: ReactTestInstance) => ( testId: string, diff --git a/src/helpers/makeQuery.js b/src/helpers/makeQuery.js index 2aec42c7d..04e41a18d 100644 --- a/src/helpers/makeQuery.js +++ b/src/helpers/makeQuery.js @@ -1,5 +1,5 @@ // @flow -import waitForElement from '../waitFor'; +import waitFor from '../waitFor'; import type { WaitForOptions } from '../waitFor'; import { ErrorWithStack, @@ -70,11 +70,11 @@ const makeQuery = ( }; const findBy = (matcher: M, waitForOptions?: WaitForOptions) => { - return waitForElement(() => getBy(matcher), waitForOptions); + return waitFor(() => getBy(matcher), waitForOptions); }; const findAllBy = (matcher: M, waitForOptions?: WaitForOptions) => { - return waitForElement(() => getAllBy(matcher), waitForOptions); + return waitFor(() => getAllBy(matcher), waitForOptions); }; return { diff --git a/src/index.js b/src/index.js index 945488dc7..40f4dd4e9 100644 --- a/src/index.js +++ b/src/index.js @@ -6,7 +6,7 @@ import fireEvent from './fireEvent'; import flushMicrotasksQueue from './flushMicrotasksQueue'; import render from './render'; import shallow from './shallow'; -import waitForElement from './waitFor'; +import waitFor from './waitFor'; import within from './within'; export { act }; @@ -16,5 +16,5 @@ export { fireEvent }; export { flushMicrotasksQueue }; export { render }; export { shallow }; -export { waitForElement }; +export { waitFor }; export { within }; diff --git a/src/waitFor.js b/src/waitFor.js index 7d4b8d55e..e947f8631 100644 --- a/src/waitFor.js +++ b/src/waitFor.js @@ -8,7 +8,7 @@ export type WaitForOptions = { interval?: number, }; -export default function waitForElement( +export default function waitFor( expectation: () => T, options?: WaitForOptions ): Promise { diff --git a/typings/__tests__/index.test.tsx b/typings/__tests__/index.test.tsx index 3caf5f299..afbe24fec 100644 --- a/typings/__tests__/index.test.tsx +++ b/typings/__tests__/index.test.tsx @@ -7,7 +7,7 @@ import { shallow, flushMicrotasksQueue, debug, - waitForElement, + waitFor, act, within, } from '../..'; @@ -262,12 +262,13 @@ debug.deep(); debug.deep(, 'message'); debug.deep(tree.toJSON()); -const waitBy: Promise = waitForElement( - () => tree.getByName('View') +const waitBy: Promise = waitFor(() => + tree.getByName('View') +); +const waitByAll: Promise = waitFor( + () => tree.getAllByName('View'), + { timeout: 1000, interval: 50 } ); -const waitByAll: Promise> = waitForElement< - Array ->(() => tree.getAllByName('View'), 1000, 50); act(() => { render(); diff --git a/typings/index.d.ts b/typings/index.d.ts index 0a5bb8d2f..2d58e07e9 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -224,10 +224,9 @@ export type FireEventAPI = FireEventFunction & { scroll: (element: ReactTestInstance, ...data: Array) => any; }; -export type WaitForElementFunction = ( +export type WaitForFunction = ( expectation: () => T, - timeout?: number, - interval?: number + { timeout?: number, interval?: number }? ) => Promise; export type DebugFunction = ( @@ -254,6 +253,6 @@ export declare const flushMicrotasksQueue: () => Promise; export declare const cleanup: () => void; export declare const debug: DebugAPI; export declare const fireEvent: FireEventAPI; -export declare const waitForElement: WaitForElementFunction; +export declare const waitFor: WaitForFunction; export declare const act: (callback: () => void) => Thenable; export declare const within: (instance: ReactTestInstance) => Queries; diff --git a/website/docs/API.md b/website/docs/API.md index 62176f09b..fd4edc13f 100644 --- a/website/docs/API.md +++ b/website/docs/API.md @@ -313,29 +313,28 @@ fireEvent.scroll(getByType(ScrollView), eventData); expect(onEndReached).toHaveBeenCalled(); ``` -## `waitForElement` +## `waitFor` -- [`Example code`](https://github.com/callstack/react-native-testing-library/blob/master/src/__tests__/waitForElement.test.js) +- [`Example code`](https://github.com/callstack/react-native-testing-library/blob/master/src/__tests__/waitFor.test.js) Defined as: ```jsx -function waitForElement( +function waitFor( expectation: () => T, - timeout: number = 4500, - interval: number = 50 + { timeout: number = 4500, interval: number = 50 } ): Promise {} ``` -Waits for non-deterministic periods of time until your element appears or times out. `waitForElement` periodically calls `expectation` every `interval` milliseconds to determine whether the element appeared or not. +Waits for non-deterministic periods of time until your element appears or times out. `waitFor` periodically calls `expectation` every `interval` milliseconds to determine whether the element appeared or not. ```jsx -import { render, waitForElement } from 'react-testing-library'; +import { render, waitFor } from 'react-testing-library'; test('waiting for an Banana to be ready', async () => { const { getByText } = render(); - await waitForElement(() => getByText('Banana ready')); + await waitFor(() => getByText('Banana ready')); }); ``` diff --git a/website/docs/Queries.md b/website/docs/Queries.md index ab1465f1a..ec428d887 100644 --- a/website/docs/Queries.md +++ b/website/docs/Queries.md @@ -32,9 +32,8 @@ title: Queries `findAllBy` queries return a promise which resolves to an array when any matching elements are found. The promise is rejected if no elements match after a default timeout of 4500ms. - :::info -`findBy` and `findAllBy` queries accept optional `waitForOptions` object argument which can contain `timeout` and `interval` properies which have the same meaning as respective arguments to [`waitForElement`](https://callstack.github.io/react-native-testing-library/docs/api#waitforelement) function. +`findBy` and `findAllBy` queries accept optional `waitForOptions` object argument which can contain `timeout` and `interval` properies which have the same meaning as respective options for [`waitFor`](https://callstack.github.io/react-native-testing-library/docs/api#waitfor) function. ::: ## Queries @@ -105,7 +104,7 @@ const element = getByTestId('unique-id'); ``` :::caution -Please be mindful when using these API and **treat it as an escape hatch**. Your users can't interact with `testID` anyhow, so you may end up writing tests that provide false sense of security. Favor text and accessibility queries instead. +Please be mindful when using these API and **treat it as an escape hatch**. Your users can't interact with `testID` anyhow, so you may end up writing tests that provide false sense of security. Favor text and accessibility queries instead. ::: :::danger From ac76f15c712fe721bf8d3a80dbe7b6a653452657 Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Mon, 18 May 2020 14:45:41 +0200 Subject: [PATCH 3/7] Migration guide entry --- website/docs/Migration20.md | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 website/docs/Migration20.md diff --git a/website/docs/Migration20.md b/website/docs/Migration20.md new file mode 100644 index 000000000..7bf653a14 --- /dev/null +++ b/website/docs/Migration20.md @@ -0,0 +1,38 @@ +--- +id: migration20 +title: Migration to 2.0 +--- + +This guides describes major steps involved in migrating your testing code from using React Native Testing Library version `1.x` to version `2.0`. + +## WaitFor API changes + +`waitForElement` function has been renamed to `waitFor` for consistency with React Testing Library. Additionally the signature has slightly changed from: + +```jsx +export default function waitForElement( + expectation: () => T, + timeout?: number, + interval?: number + : Promise { +``` + +to: + +```jsx +export default function waitFor( + expectation: () => T, + { + timeout?: number, + interval?: number + } +): Promise { +``` + +Both changes should improve code readibility. + +:::note +Please note that in many cases `waitFor` call can be replaced by proper use of `findBy` asynchonous queries resulting in more streamlined test code. +::: + +## Some `byTestId` queries behavior changes From 6a2962b5d95e56f3c45440a76ee81abce68cf1bf Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Mon, 18 May 2020 14:56:37 +0200 Subject: [PATCH 4/7] Fixed typescript check --- typings/index.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 2d58e07e9..b94c4e3e4 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -224,9 +224,14 @@ export type FireEventAPI = FireEventFunction & { scroll: (element: ReactTestInstance, ...data: Array) => any; }; +type WaitForOptions = { + timeout?: number; + interval?: number; +}; + export type WaitForFunction = ( expectation: () => T, - { timeout?: number, interval?: number }? + options?: WaitForOptions ) => Promise; export type DebugFunction = ( From a48ad6d0dbb66a74bd57195ccca86f2c4073cf4e Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Mon, 18 May 2020 16:01:15 +0200 Subject: [PATCH 5/7] Update src/helpers/a11yAPI.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michał Pierzchała --- src/helpers/a11yAPI.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/a11yAPI.js b/src/helpers/a11yAPI.js index ac62221ea..77f1b063e 100644 --- a/src/helpers/a11yAPI.js +++ b/src/helpers/a11yAPI.js @@ -1,6 +1,6 @@ // @flow import type { A11yRole, A11yStates, A11yState, A11yValue } from '../types.flow'; -import type { WaitForOptions } from '../waitFor.js'; +import type { WaitForOptions } from '../waitFor'; import makeQuery from './makeQuery'; type GetReturn = ReactTestInstance; From 3ad21b3127c3fc57fc5c3096f34e287cecee7ea5 Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Mon, 18 May 2020 16:10:01 +0200 Subject: [PATCH 6/7] (Nearly) Empty migration doc for ver. 2.0 (#326) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added migration docs section * Added to docosaurus side bar * Updated README * Increased async test timeout * Update website/docs/Migration20.md Co-authored-by: Michał Pierzchała --- README.md | 4 +++- src/__tests__/findByApi.test.js | 2 +- website/docs/Migration20.md | 8 ++++++++ website/sidebars.js | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a5be958c0..2cf3dcc68 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,9 @@ The [public API](https://callstack.github.io/react-native-testing-library/docs/a - [`within`](https://callstack.github.io/react-native-testing-library/docs/api#within) - creates a queries object scoped for given element. - [`flushMicrotasksQueue`](https://callstack.github.io/react-native-testing-library/docs/api#flushmicrotasksqueue) - waits for microtasks queue to flush. -**Note to users who are more familiar with `react-testing-library`:** This API does not expose `cleanup` because it doesn't interact with the DOM. There's nothing to clean up. +## Migration Guides + +- [Migration to 2.0](https://callstack.github.io/react-native-testing-library/docs/migration20) ## Made with ❤️ at Callstack diff --git a/src/__tests__/findByApi.test.js b/src/__tests__/findByApi.test.js index 3f15c7840..191003010 100644 --- a/src/__tests__/findByApi.test.js +++ b/src/__tests__/findByApi.test.js @@ -55,4 +55,4 @@ test('findBy queries work asynchronously', async () => { ); await expect(findByDisplayValue('Display Value')).resolves.toBeTruthy(); await expect(findAllByDisplayValue('Display Value')).resolves.toHaveLength(1); -}, 10000); +}, 20000); diff --git a/website/docs/Migration20.md b/website/docs/Migration20.md index 7bf653a14..36b97ae1f 100644 --- a/website/docs/Migration20.md +++ b/website/docs/Migration20.md @@ -36,3 +36,11 @@ Please note that in many cases `waitFor` call can be replaced by proper use of ` ::: ## Some `byTestId` queries behavior changes + +In version `1.x` `getByTestId` and `queryByTestId` could return non-native elements in tests. This was in contrast with other query functions: `getAllByTestId`, `queryAllByTestId`, `findByTestId` and `findAllByTestId` which returned only elements that would be rendered to native components (e.g. `View`, `Text`, etc). + +If you relied on setting `testID` for your custom components, you should probably set them on the root element of the returned JSX. + +:::caution +In general, you should avoid `byTestId` queries when possible and rather use queries that check things that can been seen by the user (e.g. `byText`, `byPlaceholder`, etc) or accessability queries (e.g. `byA11yHint`, `byA11yLabel`, etc). +::: diff --git a/website/sidebars.js b/website/sidebars.js index 67b9b5d86..d3c764e26 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -2,6 +2,7 @@ module.exports = { docs: { Introduction: ['getting-started'], 'API Reference': ['api', 'api-queries'], + Guides: ['migration20'], Examples: ['react-navigation', 'redux-integration'], }, }; From 0fa06dbd7d01019829ae58dffdc449cda887ef00 Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Mon, 18 May 2020 16:19:08 +0200 Subject: [PATCH 7/7] feat(breaking): remove legacy `debug` export (#328) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Removed global `debug` functions * Removed global `debug` from docs * Cleanup * Added migration section Co-authored-by: Michał Pierzchała --- .../__snapshots__/debug.test.js.snap | 57 ------------ src/__tests__/debug.test.js | 88 ------------------- src/debug.js | 42 --------- src/index.js | 2 - typings/__tests__/index.test.tsx | 12 --- typings/index.d.ts | 14 --- website/docs/API.md | 57 ------------ website/docs/Migration20.md | 4 + 8 files changed, 4 insertions(+), 272 deletions(-) delete mode 100644 src/__tests__/__snapshots__/debug.test.js.snap delete mode 100644 src/__tests__/debug.test.js delete mode 100644 src/debug.js diff --git a/src/__tests__/__snapshots__/debug.test.js.snap b/src/__tests__/__snapshots__/debug.test.js.snap deleted file mode 100644 index b1732ecc6..000000000 --- a/src/__tests__/__snapshots__/debug.test.js.snap +++ /dev/null @@ -1,57 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`debug 1`] = ` -" - -" -`; - -exports[`debug.deep 1`] = ` -" - - Press me 0 - -" -`; - -exports[`debug.deep async test 1`] = ` -" - - Press me 1 - -" -`; diff --git a/src/__tests__/debug.test.js b/src/__tests__/debug.test.js deleted file mode 100644 index baf350275..000000000 --- a/src/__tests__/debug.test.js +++ /dev/null @@ -1,88 +0,0 @@ -// @flow -/* eslint-disable no-console */ -import React from 'react'; -import { TouchableOpacity, Text } from 'react-native'; -import stripAnsi from 'strip-ansi'; -import { debug, render, fireEvent, flushMicrotasksQueue } from '..'; -import debugShallow from '../helpers/debugShallow'; - -type ConsoleLogMock = JestMockFn, void>; - -function TextComponent({ text }) { - return {text}; -} - -class Button extends React.Component { - state = { counter: 0 }; - - onPress = async () => { - await Promise.resolve(); - - this.setState({ counter: 1 }); - this.props.onPress(); - }; - - render() { - return ( - - - - ); - } -} - -test('debug', () => { - jest.spyOn(console, 'log').mockImplementation((x) => x); - const component =