node/test/parallel/test-errors-aborterror.js
Antoine du Hamel 17fba608ae
test: ensure assertions are reached on more tests
PR-URL: https://github.com/nodejs/node/pull/60726
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2025-11-17 22:10:40 +01:00

29 lines
650 B
JavaScript

// Flags: --expose-internals
'use strict';
require('../common');
const assert = require('assert');
const { AbortError } = require('internal/errors');
{
const err = new AbortError();
assert.strictEqual(err.message, 'The operation was aborted');
assert.strictEqual(err.cause, undefined);
}
{
const cause = new Error('boom');
const err = new AbortError('bang', { cause });
assert.strictEqual(err.message, 'bang');
assert.strictEqual(err.cause, cause);
}
{
assert.throws(() => new AbortError('', false), {
code: 'ERR_INVALID_ARG_TYPE'
});
assert.throws(() => new AbortError('', ''), {
code: 'ERR_INVALID_ARG_TYPE'
});
}