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 <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
aduh95 authored and pluris committed Aug 6, 2023
1 parent 686bdb0 commit 00531d3
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 00531d3

Please sign in to comment.