Files
node/test/parallel/test-vfs-fs-accessSync.js
Matteo Collina 49ad95045a vfs: unflag
Enable node:vfs by default. --no-experimental-vfs disables node:vfs
exposure and --vfs-load.

Assisted-by: pi
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/66318
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2026-10-15 07:53:03 +00:00

26 lines
739 B
JavaScript

// Flags: --disable-warning=ExperimentalWarning
'use strict';
// fs.accessSync dispatches to VFS; missing paths throw ENOENT.
require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const vfs = require('node:vfs');
const myVfs = vfs.create();
myVfs.mkdirSync('/src', { recursive: true });
myVfs.writeFileSync('/src/hello.txt', 'hello');
const mountPoint = myVfs.mount();
// Existing path succeeds
fs.accessSync(path.join(mountPoint, 'src/hello.txt'));
fs.accessSync(path.join(mountPoint, 'src/hello.txt'), fs.constants.F_OK);
// Missing path throws ENOENT
assert.throws(() => fs.accessSync(path.join(mountPoint, 'missing')),
{ code: 'ENOENT' });
myVfs.unmount();