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

Function expectsError

test/common/index.js:731–745  ·  view source on GitHub ↗
(validator, exact)

Source from the content-addressed store, hash-verified

729
730// Useful for testing expected internal/error objects
731function expectsError(validator, exact) {
732 return mustCall((...args) => {
733 if (args.length !== 1) {
734 // Do not use `assert.strictEqual()` to prevent `inspect` from
735 // always being called.
736 assert.fail(`Expected one argument, got ${inspect(args)}`);
737 }
738 const error = args.pop();
739 // The error message should be non-enumerable
740 assert.strictEqual(Object.prototype.propertyIsEnumerable.call(error, 'message'), false);
741
742 assert.throws(() => { throw error; }, validator);
743 return true;
744 }, exact);
745}
746
747function skipIfInspectorDisabled() {
748 if (!hasInspector) {

Calls 5

popMethod · 0.80
mustCallFunction · 0.70
inspectFunction · 0.50
failMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…