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

Function _expectWarning

test/common/index.js:674–700  ·  view source on GitHub ↗
(name, expected, code)

Source from the content-addressed store, hash-verified

672}
673
674function _expectWarning(name, expected, code) {
675 if (typeof expected === 'string') {
676 expected = [[expected, code]];
677 } else if (!Array.isArray(expected)) {
678 expected = Object.entries(expected).map(([a, b]) => [b, a]);
679 } else if (expected.length !== 0 && !Array.isArray(expected[0])) {
680 expected = [[expected[0], expected[1]]];
681 }
682 // Deprecation codes are mandatory, everything else is not.
683 if (name === 'DeprecationWarning') {
684 expected.forEach(([_, code]) => assert(code, `Missing deprecation code: ${expected}`));
685 }
686 return mustCall((warning) => {
687 const expectedProperties = expected.shift();
688 if (!expectedProperties) {
689 assert.fail(`Unexpected extra warning received: ${warning}`);
690 }
691 const [ message, code ] = expectedProperties;
692 assert.strictEqual(warning.name, name);
693 if (typeof message === 'string') {
694 assert.strictEqual(warning.message, message);
695 } else {
696 assert.match(warning.message, message);
697 }
698 assert.strictEqual(warning.code, code);
699 }, expected.length);
700}
701
702let catchWarning;
703

Callers 1

expectWarningFunction · 0.85

Calls 8

mustCallFunction · 0.70
mapMethod · 0.65
forEachMethod · 0.65
matchMethod · 0.65
assertFunction · 0.50
entriesMethod · 0.45
shiftMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…