From 9138b78bcb72a5ccc6699644c6333bb0f777b58b Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 1 Aug 2023 21:40:06 +0200 Subject: [PATCH] test: validate error code rather than message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/48972 Reviewed-By: Yagiz Nizipli Reviewed-By: Michaƫl Zasso Reviewed-By: Luigi Pinca --- test/es-module/test-cjs-legacyMainResolve.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/es-module/test-cjs-legacyMainResolve.js b/test/es-module/test-cjs-legacyMainResolve.js index 106aec933c2515..b121bd66adb324 100644 --- a/test/es-module/test-cjs-legacyMainResolve.js +++ b/test/es-module/test-cjs-legacyMainResolve.js @@ -82,7 +82,7 @@ describe('legacyMainResolve', () => { {}, '' ), - { message: /instance of URL/ } + { message: /instance of URL/, code: 'ERR_INVALID_ARG_TYPE' }, ); }); @@ -99,7 +99,7 @@ describe('legacyMainResolve', () => { { main: './invalid/index.js' }, '' ), - { message: /Invalid URL/ } + { code: 'ERR_INVALID_URL' }, ); }); @@ -116,7 +116,7 @@ describe('legacyMainResolve', () => { { main: undefined }, '' ), - { message: /Invalid URL/ } + { code: 'ERR_INVALID_URL' }, ); }); @@ -129,7 +129,7 @@ describe('legacyMainResolve', () => { ); assert.throws( () => legacyMainResolve(packageJsonUrl, { main: null }, packageJsonUrl), - { message: /Cannot find package/i } + { code: 'ERR_MODULE_NOT_FOUND' }, ); }); @@ -142,7 +142,7 @@ describe('legacyMainResolve', () => { ); assert.throws( () => legacyMainResolve(packageJsonUrl, { main: null }, undefined), - { message: /"base" argument must be/ } + { message: /"base" argument must be/, code: 'ERR_INVALID_ARG_TYPE' }, ); }); });