MCPcopy
hub / github.com/vitest-dev/vitest / isError

Function isError

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

Source from the content-addressed store, hash-verified

88
89// https://github.com/jestjs/jest/blob/905bcbced3d40cdf7aadc4cdf6fb731c4bb3dbe3/packages/expect-utils/src/utils.ts#L509
90export function isError(value: unknown): value is Error {
91 if (typeof Error.isError === 'function') {
92 return Error.isError(value)
93 }
94 switch (Object.prototype.toString.call(value)) {
95 case '[object Error]':
96 case '[object Exception]':
97 case '[object DOMException]':
98 return true
99 default:
100 return value instanceof Error
101 }
102};
103
104// Equality function lovingly adapted from isEqual in
105// [Underscore](http://underscorejs.org)

Callers 3

JestChaiExpectFunction · 0.90
eqFunction · 0.85
isObjectWithKeysFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected