MCPcopy Index your code
hub / github.com/nodejs/node / expectWarning

Function expectWarning

test/common/index.js:708–728  ·  view source on GitHub ↗
(nameOrMap, expected, code)

Source from the content-addressed store, hash-verified

706// name/description pair.
707// The expected messages have to be unique per `expectWarning()` call.
708function expectWarning(nameOrMap, expected, code) {
709 if (catchWarning === undefined) {
710 catchWarning = {};
711 process.on('warning', (warning) => {
712 if (!catchWarning[warning.name]) {
713 throw new TypeError(
714 `"${warning.name}" was triggered without being expected.\n` +
715 inspect(warning),
716 );
717 }
718 catchWarning[warning.name](warning);
719 });
720 }
721 if (typeof nameOrMap === 'string') {
722 catchWarning[nameOrMap] = _expectWarning(nameOrMap, expected, code);
723 } else {
724 Object.keys(nameOrMap).forEach((name) => {
725 catchWarning[name] = _expectWarning(name, nameOrMap[name]);
726 });
727 }
728}
729
730// Useful for testing expected internal/error objects
731function expectsError(validator, exact) {

Callers 8

sea.jsFile · 0.85
sea.jsFile · 0.85
sea.jsFile · 0.85
sea.jsFile · 0.85
sea.jsFile · 0.85

Calls 5

_expectWarningFunction · 0.85
forEachMethod · 0.65
keysMethod · 0.65
inspectFunction · 0.50
onMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…