* Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow
( methodName: string, stringsToIgnore: Array<string>, )
| 8 | */ |
| 9 | |
| 10 | function ignoreStrings( |
| 11 | methodName: string, |
| 12 | stringsToIgnore: Array<string>, |
| 13 | ): void { |
| 14 | // $FlowFixMe[prop-missing] index access only allowed for objects with index keys |
| 15 | console[methodName] = (...args: $ReadOnlyArray<mixed>) => { |
| 16 | const maybeString = args[0]; |
| 17 | if (typeof maybeString === 'string') { |
| 18 | for (let i = 0; i < stringsToIgnore.length; i++) { |
| 19 | if (maybeString.startsWith(stringsToIgnore[i])) { |
| 20 | return; |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | // HACKY In the test harness, DevTools overrides the parent window's console. |
| 26 | // Our test app code uses the iframe's console though. |
| 27 | // To simulate a more accurate end-to-end environment, |
| 28 | // the shell's console patching should pass through to the parent override methods. |
| 29 | window.parent.console[methodName](...args); |
| 30 | }; |
| 31 | } |
| 32 | |
| 33 | export function ignoreErrors(errorsToIgnore: Array<string>): void { |
| 34 | ignoreStrings('error', errorsToIgnore); |
no outgoing calls
no test coverage detected