diff --git a/test/parallel/test-path-resolve.js b/test/parallel/test-path-resolve.js index e9e6d83ff54..ed3c7c4c5a0 100644 --- a/test/parallel/test-path-resolve.js +++ b/test/parallel/test-path-resolve.js @@ -69,3 +69,12 @@ if (common.isWindows) { const resolvedPath = spawnResult.stdout.toString().trim(); assert.strictEqual(resolvedPath.toLowerCase(), process.cwd().toLowerCase()); } + +if (!common.isWindows) { + // Test handling relative paths to be safe when process.cwd() fails. + process.cwd = () => ''; + assert.strictEqual(process.cwd(), ''); + const resolved = path.resolve(); + const expected = '.'; + assert.strictEqual(resolved, expected); +}