diff --git a/src/helpers/deprecation.ts b/src/helpers/deprecation.ts index 80c51325d..3112574b6 100644 --- a/src/helpers/deprecation.ts +++ b/src/helpers/deprecation.ts @@ -34,3 +34,20 @@ function deprecateQuery any>( return wrapper; } + +const warned: { [functionName: string]: boolean } = {}; + +// istambul ignore next: Occasionally used +export function printDeprecationWarning(functionName: string) { + if (warned[functionName]) { + return; + } + + // eslint-disable-next-line no-console + console.warn(` + Deprecation Warning: + Use of ${functionName} is not recommended and will be deleted in future versions of @testing-library/react-native. + `); + + warned[functionName] = true; +} diff --git a/src/helpers/errors.ts b/src/helpers/errors.ts index 0079c7107..01678a12f 100644 --- a/src/helpers/errors.ts +++ b/src/helpers/errors.ts @@ -9,13 +9,6 @@ export class ErrorWithStack extends Error { } } -export const createLibraryNotSupportedError = (error: unknown): Error => - new Error( - `Currently the only supported library to search by text is "react-native".\n\n${ - error instanceof Error ? error.message : '' - }` - ); - export const prepareErrorMessage = ( // TS states that error caught in a catch close are of type `unknown` // most real cases will be `Error`, but better safe than sorry @@ -71,38 +64,3 @@ export function copyStackTrace(target: unknown, stackTraceSource: Error) { ); } } - -const warned: { [functionName: string]: boolean } = {}; - -export function printDeprecationWarning(functionName: string) { - if (warned[functionName]) { - return; - } - - // eslint-disable-next-line no-console - console.warn(` - Deprecation Warning: - Use of ${functionName} is not recommended and will be deleted in future versions of @testing-library/react-native. - `); - - warned[functionName] = true; -} - -export function throwRemovedFunctionError( - functionName: string, - docsRef: string -) { - throw new Error( - `"${functionName}" has been removed.\n\nPlease consult: https://callstack.github.io/react-native-testing-library/docs/${docsRef}` - ); -} - -export function throwRenamedFunctionError( - functionName: string, - newFunctionName: string -) { - throw new ErrorWithStack( - `The "${functionName}" function has been renamed to "${newFunctionName}". Please replace all occurrences.`, - throwRenamedFunctionError - ); -}