src/agent/util/debug-assert.ts
Properties |
| AssertionError |
AssertionError:
|
Type : Function
|
| deepEqual |
deepEqual:
|
Type : Function
|
| deepStrictEqual |
deepStrictEqual:
|
Type : Function
|
| doesNotReject |
doesNotReject:
|
Type : Function
|
| doesNotThrow |
doesNotThrow:
|
Type : Function
|
| equal |
equal:
|
Type : Function
|
| fail |
fail:
|
Type : Function
|
| ifError |
ifError:
|
Type : Function
|
| notDeepEqual |
notDeepEqual:
|
Type : Function
|
| notDeepStrictEqual |
notDeepStrictEqual:
|
Type : Function
|
| notEqual |
notEqual:
|
Type : Function
|
| notStrictEqual |
notStrictEqual:
|
Type : Function
|
| ok |
ok:
|
Type : Function
|
| rejects |
rejects:
|
Type : Function
|
| strict |
strict:
|
Type : Function
|
| strictEqual |
strictEqual:
|
Type : Function
|
| throws |
throws:
|
Type : Function
|
import * as realAssert from 'assert';
export interface FakeAssert {
deepEqual: Function;
deepStrictEqual: Function;
doesNotThrow: Function;
equal: Function;
fail: Function;
ifError: Function;
notDeepEqual: Function;
notDeepStrictEqual: Function;
notEqual: Function;
notStrictEqual: Function;
ok: Function;
strictEqual: Function;
throws: Function;
AssertionError: Function;
rejects: Function;
doesNotReject: Function;
strict: Function;
}
const nop = (_: {}) => _;
const fakeAssert: FakeAssert = {
deepEqual: nop,
deepStrictEqual: nop,
doesNotThrow: nop,
equal: nop,
fail: nop,
ifError: nop,
notDeepEqual: nop,
notDeepStrictEqual: nop,
notEqual: nop,
notStrictEqual: nop,
ok: nop,
strictEqual: nop,
throws: nop,
AssertionError: nop,
rejects: nop,
doesNotReject: nop,
strict: nop,
};
export function debugAssert(enableAssertions: boolean): FakeAssert {
// The typecast is needed since the @types/node doesn't cover Node 10 yet
return enableAssertions ? ((realAssert as {}) as FakeAssert) : fakeAssert;
}