feat: make debug.deep more usable (#40)

<!-- Please provide enough information so that others can review your pull request. -->
<!-- Keep pull requests small and focused on a single change. -->

### Summary

Make `debug.deep` more usable by allowing it to print arbitrary JSON (and actually any) files. This proves handy when we want to debug async component which we want to snapshot after async operations:

```jsx
const { toJSON, getByName } = render(
  <Button onPress={jest.fn} text="Press me" />
);
fireEvent.press(getByName('TouchableOpacity'));
await flushMicrotasksQueue();

debug.deep(toJSON());
```

### Test plan

added one
This commit is contained in:
Michał Pierzchała
2018-10-18 09:13:47 +02:00
committed by GitHub
parent 44ca90ced8
commit 6fbbe2cdf5
6 changed files with 74 additions and 12 deletions
+1
View File
@@ -90,6 +90,7 @@ debug.shallow(<TestComponent />);
debug.shallow(<TestComponent />, 'message');
debug.deep(<TestComponent />);
debug.deep(<TestComponent />, 'message');
debug.deep(tree.toJSON());
const waitBy: Promise<ReactTestInstance> = waitForElement<ReactTestInstance>(
() => tree.getByName('View')
+4 -1
View File
@@ -58,7 +58,10 @@ export type DebugFunction = (
export type DebugAPI = DebugFunction & {
shallow: DebugFunction;
deep: (instance: React.ReactElement<any>, message?: string) => void;
deep: (
instance: React.ReactElement<any> | ReactTestRendererJSON | null,
message?: string
) => void;
};
export declare const render: (