How to use the AssertionError function from assert-plus

Find comprehensive JavaScript assert-plus.AssertionError code examples handpicked from public code repositorys.

758
759
760
761
762
763
764
765
766
767
 * already been done) or opts.insecure (this module's chosen name
 * for this thing).
 */
var rejectUnauthorized;
if (opts.insecure !== undefined && opts.rejectUnauthorized !== undefined) {
    throw new assert.AssertionError(
        'cannot set both opts.insecure and opts.rejectUnauthorized');
} else if (opts.insecure !== undefined) {
    rejectUnauthorized = !opts.insecure;
} else if (opts.rejectUnauthorized !== undefined) {
fork icon35
star icon59
watch icon0

1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
assert.object(options, 'options');
assert.string(options.repo, 'options.repo');
assert.optionalString(options.tag, 'options.tag');
assert.optionalString(options.digest, 'options.digest');
if (!options.tag && !options.digest) {
    throw new assert.AssertionError({ message:
        'one of "options.tag" or "options.digest" is required' });
}
assert.optionalString(options.regAuth, 'options.regAuth');
assert.optionalString(options.regConfig, 'options.regConfig');
fork icon13
star icon2
watch icon36

347
348
349
350
351
352
353
354
355
356
 */
Amon.prototype.getAlarm = function getAlarm(user, id, callback) {
    assert.string(user, 'user');
    assert.number(id, 'id');
    if (!/^\d+$/.test(String(id))) {
        throw new assert.AssertionError({
            message: format('id is not a positive integer: %s', id),
            actual: typeof (id), expected: 'integer', operator: '==='});
    }
    assert.func(callback, 'callback');
fork icon13
star icon2
watch icon0

+ 3 other calls in file

167
168
169
170
171
172
173
174
175
176
177
178
179
    });
});




test('use - throws TypeError on non function as argument', function (t) {
    var err = assert.AssertionError('handler (function) is required');


    t.throws(function () {
        SERVER.use('/nonfn');
    }, err);
fork icon0
star icon0
watch icon0