MCPcopy
hub / github.com/jestjs/jest / isError

Function isError

packages/expect-utils/src/utils.ts:559–568  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

557
558// Copied from https://github.com/graingert/angular.js/blob/a43574052e9775cbc1d7dd8a086752c979b0f020/src/Angular.js#L685-L693
559export const isError = (value: unknown): value is Error => {
560 switch (Object.prototype.toString.call(value)) {
561 case '[object Error]':
562 case '[object Exception]':
563 case '[object DOMException]':
564 return true;
565 default:
566 return value instanceof Error;
567 }
568};
569
570export function emptyObject(obj: unknown): boolean {
571 return obj && typeof obj === 'object' ? Object.keys(obj).length === 0 : false;

Callers 4

createMatcherFunction · 0.90
isError.test.tsFile · 0.90
nativeEsm.test.tsFile · 0.50

Calls

no outgoing calls

Tested by 1