@tapjs/asserts
Advanced tools
Comparing version 1.2.0 to 2.0.0
@@ -20,7 +20,11 @@ /// <reference types="node" /> | ||
}; | ||
export type ErrorCauseMatch = { | ||
cause: any; | ||
export type ErrorCauseMatch<C extends {}> = { | ||
cause: C; | ||
[k: string]: any; | ||
}; | ||
export type ErrorMatch = Error | typeof Error | ErrorMessageMatch | ErrorNameMatch | ErrorCodeMatch | ErrorCauseMatch | RegExp; | ||
export type ErrorErrorsMatch<C extends {}> = { | ||
errors: C[]; | ||
[k: string]: any; | ||
}; | ||
export type ErrorMatch = Error | typeof Error | ErrorMessageMatch | ErrorNameMatch | ErrorCodeMatch | ErrorCauseMatch<{}> | ErrorErrorsMatch<{}> | RegExp; | ||
export type ThrowsArgs = [] | [msg: string, extra?: Extra] | [wanted: ErrorMatch, ...messageExtra: MessageExtra]; | ||
@@ -27,0 +31,0 @@ export type ExpectedEmit = [ |
@@ -160,4 +160,4 @@ "use strict"; | ||
this.#t.currentAssert = this.#t.t.type; | ||
const name = typeof klass === 'function' | ||
? klass.name || '(anonymous constructor)' | ||
const name = typeof klass === 'function' ? | ||
klass.name || '(anonymous constructor)' | ||
: klass; | ||
@@ -171,11 +171,10 @@ const args = [msg, extra]; | ||
const tof = typeof obj; | ||
const type = !obj && tof === 'object' | ||
? 'null' | ||
: // treat as object, but not Object | ||
// t.type(() => {}, Function) | ||
tof === 'function' && | ||
typeof klass === 'function' && | ||
klass !== Object | ||
? 'object' | ||
: tof; | ||
const type = !obj && tof === 'object' ? 'null' | ||
// treat as object, but not Object | ||
// t.type(() => {}, Function) | ||
: (tof === 'function' && | ||
typeof klass === 'function' && | ||
klass !== Object) ? | ||
'object' | ||
: tof; | ||
if ((type === 'number' && klass === Number) || | ||
@@ -642,4 +641,4 @@ (type === 'string' && klass === String) || | ||
} | ||
return ((w | ||
? this.match(isRegExp(wanted) ? er.message : er, wanted, m, e) | ||
return ((w ? | ||
this.match(isRegExp(wanted) ? er.message : er, wanted, m, e) | ||
: this.#t.pass(m, e)) && er); | ||
@@ -665,4 +664,4 @@ } | ||
// pull the errorOrigin from the thrown error, if possible | ||
const res = er !== undefined && er !== null | ||
? this.error(er, ...me) | ||
const res = er !== undefined && er !== null ? | ||
this.error(er, ...me) | ||
: this.#t.fail(...me); | ||
@@ -687,5 +686,3 @@ return (res && er) || res; | ||
p = | ||
typeof fnOrPromise === 'function' | ||
? fnOrPromise() | ||
: fnOrPromise; | ||
typeof fnOrPromise === 'function' ? fnOrPromise() : (fnOrPromise); | ||
} | ||
@@ -714,4 +711,4 @@ catch (er) { | ||
} | ||
d.resolve((w | ||
? this.match(isRegExp(w) ? er.message : er, w, m, e) | ||
d.resolve((w ? | ||
this.match(isRegExp(w) ? er.message : er, w, m, e) | ||
: this.#t.pass(m, e)) && | ||
@@ -737,5 +734,3 @@ (er || true)); | ||
p = | ||
typeof fnOrPromise === 'function' | ||
? fnOrPromise() | ||
: fnOrPromise; | ||
typeof fnOrPromise === 'function' ? fnOrPromise() : (fnOrPromise); | ||
} | ||
@@ -756,4 +751,4 @@ catch (er) { | ||
// pull the errorOrigin from the thrown error, if possible | ||
const res = er !== undefined && er !== null | ||
? this.error(er, ...me) | ||
const res = er !== undefined && er !== null ? | ||
this.error(er, ...me) | ||
: this.#t.fail(...me); | ||
@@ -781,5 +776,3 @@ d.resolve((res && er) || res); | ||
p = | ||
typeof fnOrPromise === 'function' | ||
? fnOrPromise() | ||
: fnOrPromise; | ||
typeof fnOrPromise === 'function' ? fnOrPromise() : (fnOrPromise); | ||
} | ||
@@ -799,4 +792,4 @@ catch (er) { | ||
// pull the errorOrigin from the thrown error, if possible | ||
d.resolve(er !== undefined && er !== null | ||
? this.error(er, ...me) | ||
d.resolve(er !== undefined && er !== null ? | ||
this.error(er, ...me) | ||
: this.#t.fail(...me)); | ||
@@ -891,6 +884,12 @@ } | ||
// or respect the at/stack added by another caller. | ||
ex.errorOrigin = { | ||
// iow, the "main" error is `t.error(...)`, but the "cause" | ||
// callsite is whatever the error refers to. | ||
const { cause } = ex; | ||
ex.cause = { | ||
message: er.message || msg, | ||
at: ex.at, | ||
stack: ex.stack, | ||
}; | ||
if (cause !== undefined) | ||
ex.cause.cause = cause; | ||
ex.at = at; | ||
@@ -897,0 +896,0 @@ ex.stack = stack; |
@@ -20,7 +20,11 @@ /// <reference types="node" resolution-mode="require"/> | ||
}; | ||
export type ErrorCauseMatch = { | ||
cause: any; | ||
export type ErrorCauseMatch<C extends {}> = { | ||
cause: C; | ||
[k: string]: any; | ||
}; | ||
export type ErrorMatch = Error | typeof Error | ErrorMessageMatch | ErrorNameMatch | ErrorCodeMatch | ErrorCauseMatch | RegExp; | ||
export type ErrorErrorsMatch<C extends {}> = { | ||
errors: C[]; | ||
[k: string]: any; | ||
}; | ||
export type ErrorMatch = Error | typeof Error | ErrorMessageMatch | ErrorNameMatch | ErrorCodeMatch | ErrorCauseMatch<{}> | ErrorErrorsMatch<{}> | RegExp; | ||
export type ThrowsArgs = [] | [msg: string, extra?: Extra] | [wanted: ErrorMatch, ...messageExtra: MessageExtra]; | ||
@@ -27,0 +31,0 @@ export type ExpectedEmit = [ |
@@ -131,4 +131,4 @@ import { extraFromError, normalizeMessageExtra, } from '@tapjs/core'; | ||
this.#t.currentAssert = this.#t.t.type; | ||
const name = typeof klass === 'function' | ||
? klass.name || '(anonymous constructor)' | ||
const name = typeof klass === 'function' ? | ||
klass.name || '(anonymous constructor)' | ||
: klass; | ||
@@ -142,11 +142,10 @@ const args = [msg, extra]; | ||
const tof = typeof obj; | ||
const type = !obj && tof === 'object' | ||
? 'null' | ||
: // treat as object, but not Object | ||
// t.type(() => {}, Function) | ||
tof === 'function' && | ||
typeof klass === 'function' && | ||
klass !== Object | ||
? 'object' | ||
: tof; | ||
const type = !obj && tof === 'object' ? 'null' | ||
// treat as object, but not Object | ||
// t.type(() => {}, Function) | ||
: (tof === 'function' && | ||
typeof klass === 'function' && | ||
klass !== Object) ? | ||
'object' | ||
: tof; | ||
if ((type === 'number' && klass === Number) || | ||
@@ -613,4 +612,4 @@ (type === 'string' && klass === String) || | ||
} | ||
return ((w | ||
? this.match(isRegExp(wanted) ? er.message : er, wanted, m, e) | ||
return ((w ? | ||
this.match(isRegExp(wanted) ? er.message : er, wanted, m, e) | ||
: this.#t.pass(m, e)) && er); | ||
@@ -636,4 +635,4 @@ } | ||
// pull the errorOrigin from the thrown error, if possible | ||
const res = er !== undefined && er !== null | ||
? this.error(er, ...me) | ||
const res = er !== undefined && er !== null ? | ||
this.error(er, ...me) | ||
: this.#t.fail(...me); | ||
@@ -658,5 +657,3 @@ return (res && er) || res; | ||
p = | ||
typeof fnOrPromise === 'function' | ||
? fnOrPromise() | ||
: fnOrPromise; | ||
typeof fnOrPromise === 'function' ? fnOrPromise() : (fnOrPromise); | ||
} | ||
@@ -685,4 +682,4 @@ catch (er) { | ||
} | ||
d.resolve((w | ||
? this.match(isRegExp(w) ? er.message : er, w, m, e) | ||
d.resolve((w ? | ||
this.match(isRegExp(w) ? er.message : er, w, m, e) | ||
: this.#t.pass(m, e)) && | ||
@@ -708,5 +705,3 @@ (er || true)); | ||
p = | ||
typeof fnOrPromise === 'function' | ||
? fnOrPromise() | ||
: fnOrPromise; | ||
typeof fnOrPromise === 'function' ? fnOrPromise() : (fnOrPromise); | ||
} | ||
@@ -727,4 +722,4 @@ catch (er) { | ||
// pull the errorOrigin from the thrown error, if possible | ||
const res = er !== undefined && er !== null | ||
? this.error(er, ...me) | ||
const res = er !== undefined && er !== null ? | ||
this.error(er, ...me) | ||
: this.#t.fail(...me); | ||
@@ -752,5 +747,3 @@ d.resolve((res && er) || res); | ||
p = | ||
typeof fnOrPromise === 'function' | ||
? fnOrPromise() | ||
: fnOrPromise; | ||
typeof fnOrPromise === 'function' ? fnOrPromise() : (fnOrPromise); | ||
} | ||
@@ -770,4 +763,4 @@ catch (er) { | ||
// pull the errorOrigin from the thrown error, if possible | ||
d.resolve(er !== undefined && er !== null | ||
? this.error(er, ...me) | ||
d.resolve(er !== undefined && er !== null ? | ||
this.error(er, ...me) | ||
: this.#t.fail(...me)); | ||
@@ -862,6 +855,12 @@ } | ||
// or respect the at/stack added by another caller. | ||
ex.errorOrigin = { | ||
// iow, the "main" error is `t.error(...)`, but the "cause" | ||
// callsite is whatever the error refers to. | ||
const { cause } = ex; | ||
ex.cause = { | ||
message: er.message || msg, | ||
at: ex.at, | ||
stack: ex.stack, | ||
}; | ||
if (cause !== undefined) | ||
ex.cause.cause = cause; | ||
ex.at = at; | ||
@@ -868,0 +867,0 @@ ex.stack = stack; |
{ | ||
"name": "@tapjs/asserts", | ||
"version": "1.2.0", | ||
"version": "2.0.0", | ||
"description": "", | ||
@@ -43,9 +43,9 @@ "tshy": { | ||
"dependencies": { | ||
"@tapjs/stack": "1.2.8", | ||
"@tapjs/stack": "2.0.0", | ||
"is-actual-promise": "^1.0.1", | ||
"tcompare": "6.4.6", | ||
"tcompare": "7.0.0", | ||
"trivial-deferred": "^2.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@tapjs/core": "1.5.4" | ||
"@tapjs/core": "2.0.0" | ||
}, | ||
@@ -52,0 +52,0 @@ "tap": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
239890
2413
+ Added@tapjs/after@1.1.23(transitive)
+ Added@tapjs/after-each@2.0.0(transitive)
+ Added@tapjs/before@2.0.0(transitive)
+ Added@tapjs/before-each@2.0.0(transitive)
+ Added@tapjs/core@2.0.0(transitive)
+ Added@tapjs/error-serdes@2.0.0(transitive)
+ Added@tapjs/filter@2.0.0(transitive)
+ Added@tapjs/fixture@2.0.0(transitive)
+ Added@tapjs/intercept@2.0.0(transitive)
+ Added@tapjs/mock@2.0.0(transitive)
+ Added@tapjs/node-serialize@2.0.0(transitive)
+ Added@tapjs/snapshot@2.0.0(transitive)
+ Added@tapjs/spawn@2.0.0(transitive)
+ Added@tapjs/stack@2.0.0(transitive)
+ Added@tapjs/stdin@2.0.0(transitive)
+ Added@tapjs/test@2.0.0(transitive)
+ Added@tapjs/typescript@1.4.5(transitive)
+ Added@tapjs/worker@2.0.0(transitive)
+ Addedtap-parser@16.0.0(transitive)
+ Addedtcompare@7.0.0(transitive)
+ Addedtypescript@5.4.5(transitive)
- Removed@tapjs/after@1.1.22(transitive)
- Removed@tapjs/after-each@1.1.22(transitive)
- Removed@tapjs/before@1.1.22(transitive)
- Removed@tapjs/before-each@1.1.22(transitive)
- Removed@tapjs/core@1.5.4(transitive)
- Removed@tapjs/error-serdes@1.2.2(transitive)
- Removed@tapjs/filter@1.2.22(transitive)
- Removed@tapjs/fixture@1.2.22(transitive)
- Removed@tapjs/intercept@1.2.22(transitive)
- Removed@tapjs/mock@1.3.4(transitive)
- Removed@tapjs/node-serialize@1.3.4(transitive)
- Removed@tapjs/snapshot@1.2.22(transitive)
- Removed@tapjs/spawn@1.1.22(transitive)
- Removed@tapjs/stack@1.2.8(transitive)
- Removed@tapjs/stdin@1.1.22(transitive)
- Removed@tapjs/test@1.4.4(transitive)
- Removed@tapjs/typescript@1.4.4(transitive)
- Removed@tapjs/worker@1.1.22(transitive)
- Removedjackspeak@2.3.6(transitive)
- Removedtap-parser@15.3.2(transitive)
- Removedtcompare@6.4.6(transitive)
- Removedtypescript@5.2.2(transitive)
Updated@tapjs/stack@2.0.0
Updatedtcompare@7.0.0