diff --git a/test/parallel/test-fs-read-empty-buffer.js b/test/parallel/test-fs-read-empty-buffer.js index 6abfcb5aae6..65ed3ee0052 100644 --- a/test/parallel/test-fs-read-empty-buffer.js +++ b/test/parallel/test-fs-read-empty-buffer.js @@ -29,7 +29,7 @@ assert.throws( ); (async () => { - const filehandle = await fsPromises.open(filepath, 'r'); + await using filehandle = await fsPromises.open(filepath, 'r'); assert.rejects( () => filehandle.read(buffer, 0, 1, 0), { diff --git a/test/parallel/test-fs-read-offset-null.js b/test/parallel/test-fs-read-offset-null.js index 012c94e41e9..4104fe14113 100644 --- a/test/parallel/test-fs-read-offset-null.js +++ b/test/parallel/test-fs-read-offset-null.js @@ -35,30 +35,25 @@ fs.open(filepath, 'r', common.mustSucceed((fd) => { })); })); -let filehandle = null; - // Tests for promises api (async () => { - filehandle = await fsPromises.open(filepath, 'r'); + await using filehandle = await fsPromises.open(filepath, 'r'); const readObject = await filehandle.read(buf, { offset: null }); assert.strictEqual(readObject.buffer[0], 120); })() -.finally(() => filehandle?.close()) .then(common.mustCall()); // Undocumented: omitted position works the same as position === null (async () => { - filehandle = await fsPromises.open(filepath, 'r'); + await using filehandle = await fsPromises.open(filepath, 'r'); const readObject = await filehandle.read(buf, null, buf.length); assert.strictEqual(readObject.buffer[0], 120); })() -.finally(() => filehandle?.close()) .then(common.mustCall()); (async () => { - filehandle = await fsPromises.open(filepath, 'r'); + await using filehandle = await fsPromises.open(filepath, 'r'); const readObject = await filehandle.read(buf, null, buf.length, 0); assert.strictEqual(readObject.buffer[0], 120); })() -.finally(() => filehandle?.close()) .then(common.mustCall());