node/test/parallel/test-process-chdir-errormessage.js
Anna Henningsen cf37945b12
src: include cwd in chdir error message
Include the current working directory in the error
message for a failing `process.chdir()` since that is
usually information relevant for debugging.

This is semver-major because it moves properties
of the error message object.

Inspired by https://github.com/nodejs/help/issues/1355.

PR-URL: https://github.com/nodejs/node/pull/21526
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-07-17 13:57:11 +02:00

20 lines
414 B
JavaScript

'use strict';
const common = require('../common');
if (!common.isMainThread)
common.skip('process.chdir is not available in Workers');
common.expectsError(
() => {
process.chdir('does-not-exist');
},
{
type: Error,
code: 'ENOENT',
message: /ENOENT: no such file or directory, chdir .+ -> 'does-not-exist'/,
path: process.cwd(),
syscall: 'chdir',
dest: 'does-not-exist'
}
);