mirror of
https://github.com/callstack/react-native-testing-library.git
synced 2026-09-18 23:09:04 +08:00
22 lines
599 B
JavaScript
22 lines
599 B
JavaScript
|
|
// @flow
|
||
|
|
import * as React from 'react';
|
||
|
|
import prettyFormat, { plugins } from 'pretty-format'; // eslint-disable-line import/no-extraneous-dependencies
|
||
|
|
import shallow from './shallow';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Log pretty-printed shallow test component instance
|
||
|
|
*/
|
||
|
|
export default function debug(
|
||
|
|
instance: ReactTestInstance | React.Element<*>,
|
||
|
|
message?: any
|
||
|
|
) {
|
||
|
|
const { output } = shallow(instance);
|
||
|
|
// eslint-disable-next-line no-console
|
||
|
|
console.log(format(output), message || '');
|
||
|
|
}
|
||
|
|
|
||
|
|
const format = input =>
|
||
|
|
prettyFormat(input, {
|
||
|
|
plugins: [plugins.ReactTestComponent, plugins.ReactElement],
|
||
|
|
});
|