From 088075abd93464610797d01da7ad26cf3d988e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 16 Oct 2018 19:21:47 +0200 Subject: [PATCH 1/3] feat: add debug.deep and debug.shallow --- package.json | 1 + .../__snapshots__/debug.test.js.snap | 34 +++++++++++ src/__tests__/debug.test.js | 60 +++++++++++++++++++ src/debug.js | 23 ++++++- yarn.lock | 12 ++++ 5 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 src/__tests__/__snapshots__/debug.test.js.snap create mode 100644 src/__tests__/debug.test.js diff --git a/package.json b/package.json index 9aad03b10..5736f17bf 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "react": "16.6.0-alpha.8af6728", "react-native": "^0.57.3", "react-test-renderer": "16.6.0-alpha.8af6728", + "strip-ansi": "^5.0.0", "typescript": "^3.1.1" }, "peerDependencies": { diff --git a/src/__tests__/__snapshots__/debug.test.js.snap b/src/__tests__/__snapshots__/debug.test.js.snap new file mode 100644 index 000000000..2a595cfa1 --- /dev/null +++ b/src/__tests__/__snapshots__/debug.test.js.snap @@ -0,0 +1,34 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`debug 1`] = ` +" + +" +`; + +exports[`debug.deep 1`] = ` +" + + Press me + +" +`; diff --git a/src/__tests__/debug.test.js b/src/__tests__/debug.test.js new file mode 100644 index 000000000..758280cea --- /dev/null +++ b/src/__tests__/debug.test.js @@ -0,0 +1,60 @@ +// @flow +/* eslint-disable no-console */ +import React from 'react'; +import { TouchableOpacity, Text } from 'react-native'; +import stripAnsi from 'strip-ansi'; +import { debug } from '..'; + +function TextComponent({ text }) { + return {text}; +} + +class Button extends React.Component<*> { + render() { + return ( + + + + ); + } +} + +test('debug', () => { + // $FlowFixMe + console.log = jest.fn(); + const component =