mirror of
https://github.com/callstack/react-native-testing-library.git
synced 2026-09-18 23:09:04 +08:00
c5910d94e4
<!-- Please provide enough information so that others can review your pull request. --> <!-- Keep pull requests small and focused on a single change. --> ### Summary Existential type (`*`) is long deprecated, let's just use `any` for now. ### Test plan Added some more Flow typings to `shallow.test.js` that were failing because of existential type.
43 lines
1010 B
JavaScript
43 lines
1010 B
JavaScript
// @flow
|
|
/* eslint-disable no-console */
|
|
import * as React from 'react';
|
|
import render from './render';
|
|
import debugShallow from './helpers/debugShallow';
|
|
import debugDeep from './helpers/debugDeep';
|
|
import format from './helpers/format';
|
|
|
|
/**
|
|
* Log pretty-printed deep test component instance
|
|
*/
|
|
function debugDeepElementOrInstance(
|
|
instance: React.Element<any> | ?ReactTestRendererJSON,
|
|
message?: any = ''
|
|
) {
|
|
try {
|
|
// We're assuming React.Element<any> here and fallback to
|
|
// rendering ?ReactTestRendererJSON
|
|
// $FlowFixMe
|
|
const { toJSON } = render(instance);
|
|
if (message) {
|
|
console.log(`${message}\n\n`, format(toJSON()));
|
|
} else {
|
|
console.log(format(toJSON()));
|
|
}
|
|
} catch (e) {
|
|
// $FlowFixMe
|
|
debugDeep(instance);
|
|
}
|
|
}
|
|
|
|
function debug(
|
|
instance: ReactTestInstance | React.Element<any>,
|
|
message?: any
|
|
) {
|
|
return debugShallow(instance, message);
|
|
}
|
|
|
|
debug.shallow = debugShallow;
|
|
debug.deep = debugDeepElementOrInstance;
|
|
|
|
export default debug;
|