Files
callstack__react-native-tes…/src/helpers/errors.js
T
2018-11-19 15:16:33 +01:00

41 lines
1015 B
JavaScript

// @flow
export class ErrorWithStack extends Error {
constructor(message: ?string, callsite: Function) {
super(message);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, callsite);
}
}
}
export const createLibraryNotSupportedError = (error: Error) =>
new Error(
`Currently the only supported library to search by text is "react-native".\n\n${
error.message
}`
);
const warned = {
getByName: false,
getAllByName: false,
queryByName: false,
queryAllByName: false,
};
export const logDeprecationWarning = (
deprecatedFnName: string,
alternativeFnName: string
) => {
if (warned[deprecatedFnName]) {
return;
}
console.warn(`Deprecation Warning:
"${deprecatedFnName}" is deprecated and will be removed in next major release. Please use "${alternativeFnName}" instead.
Docs: https://github.com/callstack/react-native-testing-library#${alternativeFnName.toLowerCase()}-type-reactcomponenttype
`);
warned[deprecatedFnName] = true;
};