Files
callstack__react-native-tes…/src/debug.js
T
Michał Pierzchała c5910d94e4 fix: remove deprecated existential Flow type and use any for now (#77)
<!-- 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.
2018-11-28 12:49:15 +01:00

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;