diff --git a/README.md b/README.md index 961d2ff44..a6df746f9 100644 --- a/README.md +++ b/README.md @@ -295,6 +295,7 @@ There's also `debug.deep` that renders deeply to stdout. import { debug } from 'react-native-testing-library'; debug.deep(); +debug.deep(toJSON(), 'actually debug JSON too'); // useful when Component state changes ``` logs: diff --git a/src/__tests__/__snapshots__/debug.test.js.snap b/src/__tests__/__snapshots__/debug.test.js.snap index 2a595cfa1..8bef21dcb 100644 --- a/src/__tests__/__snapshots__/debug.test.js.snap +++ b/src/__tests__/__snapshots__/debug.test.js.snap @@ -3,10 +3,10 @@ exports[`debug 1`] = ` " " `; @@ -28,7 +28,29 @@ exports[`debug.deep 1`] = ` } > - Press me + 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 index 758280cea..d887e8980 100644 --- a/src/__tests__/debug.test.js +++ b/src/__tests__/debug.test.js @@ -3,17 +3,26 @@ import React from 'react'; import { TouchableOpacity, Text } from 'react-native'; import stripAnsi from 'strip-ansi'; -import { debug } from '..'; +import { debug, render, fireEvent, flushMicrotasksQueue } from '..'; function TextComponent({ text }) { return {text}; } -class Button extends React.Component<*> { +class Button extends React.Component<*, *> { + state = { counter: 0 }; + + onPress = async () => { + await Promise.resolve(); + + this.setState({ counter: 1 }); + this.props.onPress(); + }; + render() { return ( - - + + ); } @@ -58,3 +67,20 @@ test('debug.deep', () => { expect(console.log).toBeCalledWith(output, 'test message'); }); + +test('debug.deep async test', async () => { + // $FlowFixMe + console.log = jest.fn(); + const { toJSON, getByName } = render( +