Skip to content

Commit

Permalink
test: validate error code rather than message
Browse files Browse the repository at this point in the history
PR-URL: nodejs#48972
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
aduh95 authored and RafaelGSS committed Aug 15, 2023
1 parent a639825 commit 794a551
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/es-module/test-cjs-legacyMainResolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('legacyMainResolve', () => {
{},
''
),
{ message: /instance of URL/ }
{ message: /instance of URL/, code: 'ERR_INVALID_ARG_TYPE' },
);
});

Expand All @@ -99,7 +99,7 @@ describe('legacyMainResolve', () => {
{ main: './invalid/index.js' },
''
),
{ message: /Invalid URL/ }
{ code: 'ERR_INVALID_URL' },
);
});

Expand All @@ -116,7 +116,7 @@ describe('legacyMainResolve', () => {
{ main: undefined },
''
),
{ message: /Invalid URL/ }
{ code: 'ERR_INVALID_URL' },
);
});

Expand All @@ -129,7 +129,7 @@ describe('legacyMainResolve', () => {
);
assert.throws(
() => legacyMainResolve(packageJsonUrl, { main: null }, packageJsonUrl),
{ message: /Cannot find package/i }
{ code: 'ERR_MODULE_NOT_FOUND' },
);
});

Expand All @@ -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' },
);
});
});

0 comments on commit 794a551

Please sign in to comment.