Skip to content

Commit 9138b78

Browse files
aduh95RafaelGSS
authored andcommitted
test: validate error code rather than message
PR-URL: #48972 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent c1bd680 commit 9138b78

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/es-module/test-cjs-legacyMainResolve.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('legacyMainResolve', () => {
8282
{},
8383
''
8484
),
85-
{ message: /instance of URL/ }
85+
{ message: /instance of URL/, code: 'ERR_INVALID_ARG_TYPE' },
8686
);
8787
});
8888

@@ -99,7 +99,7 @@ describe('legacyMainResolve', () => {
9999
{ main: './invalid/index.js' },
100100
''
101101
),
102-
{ message: /Invalid URL/ }
102+
{ code: 'ERR_INVALID_URL' },
103103
);
104104
});
105105

@@ -116,7 +116,7 @@ describe('legacyMainResolve', () => {
116116
{ main: undefined },
117117
''
118118
),
119-
{ message: /Invalid URL/ }
119+
{ code: 'ERR_INVALID_URL' },
120120
);
121121
});
122122

@@ -129,7 +129,7 @@ describe('legacyMainResolve', () => {
129129
);
130130
assert.throws(
131131
() => legacyMainResolve(packageJsonUrl, { main: null }, packageJsonUrl),
132-
{ message: /Cannot find package/i }
132+
{ code: 'ERR_MODULE_NOT_FOUND' },
133133
);
134134
});
135135

@@ -142,7 +142,7 @@ describe('legacyMainResolve', () => {
142142
);
143143
assert.throws(
144144
() => legacyMainResolve(packageJsonUrl, { main: null }, undefined),
145-
{ message: /"base" argument must be/ }
145+
{ message: /"base" argument must be/, code: 'ERR_INVALID_ARG_TYPE' },
146146
);
147147
});
148148
});

0 commit comments

Comments
 (0)