MCPcopy Index your code
hub / github.com/callstack/react-native-testing-library / formatErrorMessage

Function formatErrorMessage

src/queries/make-queries.ts:85–100  ·  view source on GitHub ↗
(message: string, printElementTree: boolean)

Source from the content-addressed store, hash-verified

83}
84
85function formatErrorMessage(message: string, printElementTree: boolean) {
86 if (!printElementTree) {
87 return message;
88 }
89
90 if (screen.isDetached) {
91 return `${message}\n\nScreen is no longer attached. Check your test for "findBy*" or "waitFor" calls that have not been awaited.\n\nWe recommend enabling "eslint-plugin-testing-library" to catch these issues at build time:\nhttps://oss.callstack.com/react-native-testing-library/docs/start/quick-start#eslint-plugin`;
92 }
93
94 const json = screen.toJSON();
95 if (!json) {
96 return message;
97 }
98
99 return `${message}\n\n${formatJson(json)}`;
100}
101
102function appendElementTreeToError(error: Error) {
103 const oldMessage = error.message;

Callers 4

appendElementTreeToErrorFunction · 0.85
getAllByQueryFunction · 0.85
queryByQueryFunction · 0.85
getByQueryFunction · 0.85

Calls 1

formatJsonFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…