script-utils/warnings-as-errors
Turns Node process warnings into test failures.
A Node 'warning' event (e.g. an ExperimentalWarning, a DeprecationWarning, or a MaxListenersExceededWarning) normally prints to stderr and is otherwise ignored. During tests that silently hides real problems — the environment or a dependency is doing something Node flags as risky, and the signal scrolls past unread. installWarningsAsErrors registers a 'warning' listener that rethrows, surfacing as an uncaught exception so the test run fails. This forces the underlying cause to be addressed (or the warning to be eliminated at its source) rather than masked.
Functions
Section titled “Functions”| Function | Description |
|---|---|
| installWarningsAsErrors | Registers a process 'warning' listener that turns every Node warning into a test failure. Idempotent: calling it more than once (e.g. from several setup files sharing one worker) registers the listener at most once, so it does not itself trigger a MaxListenersExceededWarning. |
| throwOnWarning | A process 'warning' listener that rethrows the warning as an error, failing the test run. |