From 9c96ce35c6271abbe2d3f7462d828d75b50d6591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 18 Oct 2018 00:39:50 +0200 Subject: [PATCH 1/3] feat: make debug.deep more usable --- .../__snapshots__/debug.test.js.snap | 28 +++++++++++++-- src/__tests__/debug.test.js | 34 ++++++++++++++++--- src/debug.js | 17 +++++++--- typings/__tests__/index.test.tsx | 1 + typings/index.d.ts | 5 ++- 5 files changed, 73 insertions(+), 12 deletions(-) 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( +