Skip to content

Commit 1312db5

Browse files
committed
test: test error messages from fs.realpath{Sync}
PR-URL: #17914 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 5eccbb0 commit 1312db5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/parallel/test-fs-error-messages.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ fs.lstat(fn, common.mustCall((err) => {
6464
}));
6565
}
6666

67+
fs.realpath(fn, common.mustCall((err) => {
68+
assert.strictEqual(fn, err.path);
69+
assert.strictEqual(
70+
err.message,
71+
`ENOENT: no such file or directory, lstat '${fn}'`);
72+
assert.strictEqual(err.errno, uv.UV_ENOENT);
73+
assert.strictEqual(err.code, 'ENOENT');
74+
assert.strictEqual(err.syscall, 'lstat');
75+
}));
76+
6777
fs.readlink(fn, common.mustCall((err) => {
6878
assert.ok(err.message.includes(fn));
6979
}));
@@ -181,6 +191,20 @@ try {
181191
assert.strictEqual(err.syscall, 'fstat');
182192
}
183193

194+
try {
195+
++expected;
196+
fs.realpathSync(fn);
197+
} catch (err) {
198+
errors.push('realpath');
199+
assert.strictEqual(fn, err.path);
200+
assert.strictEqual(
201+
err.message,
202+
`ENOENT: no such file or directory, lstat '${fn}'`);
203+
assert.strictEqual(err.errno, uv.UV_ENOENT);
204+
assert.strictEqual(err.code, 'ENOENT');
205+
assert.strictEqual(err.syscall, 'lstat');
206+
}
207+
184208
try {
185209
++expected;
186210
fs.readlinkSync(fn);

0 commit comments

Comments
 (0)