summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/parallel/test-dns.js28
-rw-r--r--test/parallel/test-fs-realpath.js4
-rw-r--r--test/parallel/test-fs-watchfile.js4
-rw-r--r--test/parallel/test-http-client-check-http-token.js7
-rw-r--r--test/parallel/test-http-client-reject-unexpected-agent.js6
-rw-r--r--test/parallel/test-http-client-unescaped-path.js7
-rw-r--r--test/parallel/test-http-hostname-typechecking.js12
-rw-r--r--test/parallel/test-http-request-invalid-method-error.js7
-rw-r--r--test/parallel/test-http-response-statuscode.js12
-rw-r--r--test/parallel/test-http-server-de-chunked-trailer.js4
-rw-r--r--test/parallel/test-http-write-head.js7
11 files changed, 47 insertions, 51 deletions
diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js
index 08a26ab218..f0e4b29d7c 100644
--- a/test/parallel/test-dns.js
+++ b/test/parallel/test-dns.js
@@ -68,16 +68,16 @@ const goog = [
];
assert.doesNotThrow(() => dns.setServers(goog));
assert.deepStrictEqual(dns.getServers(), goog);
-assert.throws(() => dns.setServers(['foobar']), common.expectsError({
+common.expectsError(() => dns.setServers(['foobar']), {
code: 'ERR_INVALID_IP_ADDRESS',
type: Error,
message: 'Invalid IP address: foobar'
-}));
-assert.throws(() => dns.setServers(['127.0.0.1:va']), common.expectsError({
+});
+common.expectsError(() => dns.setServers(['127.0.0.1:va']), {
code: 'ERR_INVALID_IP_ADDRESS',
type: Error,
message: 'Invalid IP address: 127.0.0.1:va'
-}));
+});
assert.deepStrictEqual(dns.getServers(), goog);
const goog6 = [
@@ -109,14 +109,14 @@ assert.deepStrictEqual(dns.getServers(), portsExpected);
assert.doesNotThrow(() => dns.setServers([]));
assert.deepStrictEqual(dns.getServers(), []);
-assert.throws(() => {
+common.expectsError(() => {
dns.resolve('example.com', [], common.mustNotCall());
-}, common.expectsError({
+}, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "rrtype" argument must be of type string. ' +
'Received type object'
-}));
+});
// dns.lookup should accept only falsey and string values
{
@@ -167,24 +167,24 @@ assert.throws(() => {
* - it's an odd number different than 1, and thus is invalid, because
* flags are either === 1 or even.
*/
-assert.throws(() => {
+common.expectsError(() => {
dns.lookup('nodejs.org', { hints: (dns.V4MAPPED | dns.ADDRCONFIG) + 1 },
common.mustNotCall());
-}, common.expectsError({
+}, {
code: 'ERR_INVALID_OPT_VALUE',
type: TypeError,
message: /The value "\d+" is invalid for option "hints"/
-}));
+});
-assert.throws(() => dns.lookup('nodejs.org'), common.expectsError({
+common.expectsError(() => dns.lookup('nodejs.org'), {
code: 'ERR_INVALID_CALLBACK',
type: TypeError
-}));
+});
-assert.throws(() => dns.lookup('nodejs.org', 4), common.expectsError({
+common.expectsError(() => dns.lookup('nodejs.org', 4), {
code: 'ERR_INVALID_CALLBACK',
type: TypeError
-}));
+});
assert.doesNotThrow(() => dns.lookup('', { family: 4, hints: 0 },
common.mustCall()));
diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js
index 4ea9bfdf48..cee45b2c89 100644
--- a/test/parallel/test-fs-realpath.js
+++ b/test/parallel/test-fs-realpath.js
@@ -225,9 +225,9 @@ function test_cyclic_link_protection(realpath, realpathSync, callback) {
fs.symlinkSync(t[1], t[0], 'dir');
unlink.push(t[0]);
});
- assert.throws(() => {
+ common.expectsError(() => {
realpathSync(entry);
- }, common.expectsError({ code: 'ELOOP', type: Error }));
+ }, { code: 'ELOOP', type: Error });
asynctest(
realpath, [entry], callback, common.mustCall(function(err, result) {
assert.strictEqual(err.path, entry);
diff --git a/test/parallel/test-fs-watchfile.js b/test/parallel/test-fs-watchfile.js
index f980d8f3fc..fe0d89c42e 100644
--- a/test/parallel/test-fs-watchfile.js
+++ b/test/parallel/test-fs-watchfile.js
@@ -24,9 +24,9 @@ common.expectsError(
type: TypeError
});
-assert.throws(function() {
+common.expectsError(function() {
fs.watchFile(new Object(), common.mustNotCall());
-}, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }));
+}, { code: 'ERR_INVALID_ARG_TYPE', type: TypeError });
const enoentFile = path.join(common.tmpDir, 'non-existent-file');
const expectedStatObject = new fs.Stats(
diff --git a/test/parallel/test-http-client-check-http-token.js b/test/parallel/test-http-client-check-http-token.js
index 7a0c894504..828d7fa79a 100644
--- a/test/parallel/test-http-client-check-http-token.js
+++ b/test/parallel/test-http-client-check-http-token.js
@@ -1,6 +1,5 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
const http = require('http');
const Countdown = require('../common/countdown');
@@ -18,14 +17,14 @@ const server = http.createServer(common.mustCall((req, res) => {
server.listen(0, common.mustCall(() => {
expectedFails.forEach((method) => {
- assert.throws(() => {
+ common.expectsError(() => {
http.request({ method, path: '/' }, common.mustNotCall());
- }, common.expectsError({
+ }, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "method" argument must be of type string. ' +
`Received type ${typeof method}`
- }));
+ });
});
expectedSuccesses.forEach((method) => {
diff --git a/test/parallel/test-http-client-reject-unexpected-agent.js b/test/parallel/test-http-client-reject-unexpected-agent.js
index 50d80fd32a..407084c030 100644
--- a/test/parallel/test-http-client-reject-unexpected-agent.js
+++ b/test/parallel/test-http-client-reject-unexpected-agent.js
@@ -47,14 +47,14 @@ server.listen(0, baseOptions.host, common.mustCall(function() {
baseOptions.port = this.address().port;
failingAgentOptions.forEach((agent) => {
- assert.throws(
+ common.expectsError(
() => createRequest(agent),
- common.expectsError({
+ {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "Agent option" argument must be one of type ' +
'Agent-like Object, undefined, or false'
- })
+ }
);
});
diff --git a/test/parallel/test-http-client-unescaped-path.js b/test/parallel/test-http-client-unescaped-path.js
index f3c680919d..6d5a945dd5 100644
--- a/test/parallel/test-http-client-unescaped-path.js
+++ b/test/parallel/test-http-client-unescaped-path.js
@@ -21,17 +21,16 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
const http = require('http');
for (let i = 0; i <= 32; i += 1) {
const path = `bad${String.fromCharCode(i)}path`;
- assert.throws(
+ common.expectsError(
() => http.get({ path }, common.mustNotCall()),
- common.expectsError({
+ {
code: 'ERR_UNESCAPED_CHARACTERS',
type: TypeError,
message: 'Request path contains unescaped characters'
- })
+ }
);
}
diff --git a/test/parallel/test-http-hostname-typechecking.js b/test/parallel/test-http-hostname-typechecking.js
index dbb98b7ae1..12fe72005a 100644
--- a/test/parallel/test-http-hostname-typechecking.js
+++ b/test/parallel/test-http-hostname-typechecking.js
@@ -9,26 +9,26 @@ const http = require('http');
const vals = [{}, [], NaN, Infinity, -Infinity, true, false, 1, 0, new Date()];
vals.forEach((v) => {
- assert.throws(
+ common.expectsError(
() => http.request({ hostname: v }),
- common.expectsError({
+ {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "options.hostname" property must be one of ' +
'type string, undefined, or null. ' +
`Received type ${typeof v}`
- })
+ }
);
- assert.throws(
+ common.expectsError(
() => http.request({ host: v }),
- common.expectsError({
+ {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "options.host" property must be one of ' +
'type string, undefined, or null. ' +
`Received type ${typeof v}`
- })
+ }
);
});
diff --git a/test/parallel/test-http-request-invalid-method-error.js b/test/parallel/test-http-request-invalid-method-error.js
index 59706e90c7..ae11985e12 100644
--- a/test/parallel/test-http-request-invalid-method-error.js
+++ b/test/parallel/test-http-request-invalid-method-error.js
@@ -1,13 +1,12 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
const http = require('http');
-assert.throws(
+common.expectsError(
() => http.request({ method: '\0' }),
- common.expectsError({
+ {
code: 'ERR_INVALID_HTTP_TOKEN',
type: TypeError,
message: 'Method must be a valid HTTP token ["\u0000"]'
- })
+ }
);
diff --git a/test/parallel/test-http-response-statuscode.js b/test/parallel/test-http-response-statuscode.js
index 17fce6c2d0..28b091a3e8 100644
--- a/test/parallel/test-http-response-statuscode.js
+++ b/test/parallel/test-http-response-statuscode.js
@@ -56,12 +56,12 @@ const server = http.Server(common.mustCall(function(req, res) {
test(res, '404 this is not valid either', '404 this is not valid either');
break;
case 12:
- assert.throws(() => { res.writeHead(); },
- common.expectsError({
- code: 'ERR_HTTP_INVALID_STATUS_CODE',
- type: RangeError,
- message: 'Invalid status code: undefined'
- }));
+ common.expectsError(() => { res.writeHead(); },
+ {
+ code: 'ERR_HTTP_INVALID_STATUS_CODE',
+ type: RangeError,
+ message: 'Invalid status code: undefined'
+ });
this.close();
break;
default:
diff --git a/test/parallel/test-http-server-de-chunked-trailer.js b/test/parallel/test-http-server-de-chunked-trailer.js
index 72c40ed559..dad744209e 100644
--- a/test/parallel/test-http-server-de-chunked-trailer.js
+++ b/test/parallel/test-http-server-de-chunked-trailer.js
@@ -14,8 +14,8 @@ const server = http.createServer(common.mustCall(function(req, res) {
message: 'Trailers are invalid with this transfer encoding',
type: Error
};
- assert.throws(() => res.writeHead(200, { 'Content-Length': '2' }),
- common.expectsError(trailerInvalidErr));
+ common.expectsError(() => res.writeHead(200, { 'Content-Length': '2' }),
+ trailerInvalidErr);
res.removeHeader('Trailer');
res.end('ok');
}));
diff --git a/test/parallel/test-http-write-head.js b/test/parallel/test-http-write-head.js
index e254f8d64d..26dc01b288 100644
--- a/test/parallel/test-http-write-head.js
+++ b/test/parallel/test-http-write-head.js
@@ -52,14 +52,13 @@ const s = http.createServer(common.mustCall((req, res) => {
res.writeHead(200, { Test: '2' });
- assert.throws(() => {
+ common.expectsError(() => {
res.writeHead(100, {});
- }, common.expectsError({
+ }, {
code: 'ERR_HTTP_HEADERS_SENT',
type: Error,
message: 'Cannot render headers after they are sent to the client'
- })
- );
+ });
res.end();
}));