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

Function parseExpectFailure

lib/internal/test_runner/test.js:528–559  ·  view source on GitHub ↗
(expectFailure)

Source from the content-addressed store, hash-verified

526}
527
528function parseExpectFailure(expectFailure) {
529 if (expectFailure === undefined || expectFailure === false) {
530 return false;
531 }
532
533 if (typeof expectFailure === 'string') {
534 return { __proto__: null, label: expectFailure, match: undefined };
535 }
536
537 if (typeof expectFailure === 'function' || isRegExp(expectFailure)) {
538 return { __proto__: null, label: undefined, match: expectFailure };
539 }
540
541 if (typeof expectFailure !== 'object') {
542 return { __proto__: null, label: undefined, match: undefined };
543 }
544
545 const keys = ObjectKeys(expectFailure);
546 if (keys.length === 0) {
547 throw new ERR_INVALID_ARG_VALUE('options.expectFailure', expectFailure, 'must not be an empty object');
548 }
549
550 if (ArrayPrototypeEvery(keys, (k) => k === 'match' || k === 'label')) {
551 return {
552 __proto__: null,
553 label: expectFailure.label,
554 match: expectFailure.match,
555 };
556 }
557
558 return { __proto__: null, label: undefined, match: expectFailure };
559}
560
561class Test extends AsyncResource {
562 reportedType = 'test';

Callers 1

constructorMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…