Skip to content

doc,test: widen fsPromises.appendFile()'s data type, add missing tests#64279

Open
hkleungai wants to merge 1 commit into
nodejs:mainfrom
hkleungai:update-fsPromises-appendFile-data-type-and-test
Open

doc,test: widen fsPromises.appendFile()'s data type, add missing tests#64279
hkleungai wants to merge 1 commit into
nodejs:mainfrom
hkleungai:update-fsPromises-appendFile-data-type-and-test

Conversation

@hkleungai

Copy link
Copy Markdown
Contributor

From lib/internal/fs/promises.js, one can see fsPromises.appendFile() is
simply a wrapper on fsPromises.writeFile(). Hence if writeFile() can
take non-buffer data argument, so can appendFile() too.

To justify the doc change, I have also restuctured the relevant tests,
to enhance the test coverage. They now includes the below test cases
consistently.

  • await do(Append|Write)Buffer();
  • await do(Append|Write)BufferAndCancel();
  • await do(Append|Write)String();
  • await do(Append|Write)Stream();
  • await do(Append|Write)StreamWithCancel();
  • await do(Append|Write)Iterable();
  • await do(Append|Write)InvalidIterable();
  • await do(Append|Write)IterableWithEncoding();
  • await do(Append|Write)BufferIterable();
  • await do(Append|Write)AsyncIterable();
  • await do(Append|Write)LargeIterable();
  • await do(Append|Write)InvalidValues();
  • await do(Append|Write)TypedArrays();

Note that test/parallel/test-fs-promises-writefile-typedarray.js is
subsumed by test/parallel/test-fs-promises-file-handle-writeFile.js, and
test/parallel/test-fs-promises-writefile-with-fd.js becomes a subcase in
test/parallel/test-fs-promises-file-handle-writeFile.js.

Refs: #41677
Signed-off-by: Jimmy Leung mingfamily@hotmail.com.hk

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Jul 4, 2026
From lib/internal/fs/promises.js, one can see fsPromises.appendFile() is
simply a wrapper on fsPromises.writeFile(). Hence if writeFile() can
take non-buffer data argument, so can appendFile() too.

To justify the doc change, I have also restuctured the relevant tests,
to enhance the test coverage. They now includes the below test cases
consistently.

- await do(Append|Write)Buffer();
- await do(Append|Write)BufferAndCancel();
- await do(Append|Write)String();
- await do(Append|Write)Stream();
- await do(Append|Write)StreamWithCancel();
- await do(Append|Write)Iterable();
- await do(Append|Write)InvalidIterable();
- await do(Append|Write)IterableWithEncoding();
- await do(Append|Write)BufferIterable();
- await do(Append|Write)AsyncIterable();
- await do(Append|Write)LargeIterable();
- await do(Append|Write)InvalidValues();
- await do(Append|Write)TypedArrays();

Note that test/parallel/test-fs-promises-writefile-typedarray.js is
subsumed by test/parallel/test-fs-promises-file-handle-writeFile.js, and
test/parallel/test-fs-promises-writefile-with-fd.js becomes a subcase in
test/parallel/test-fs-promises-file-handle-writeFile.js.

Refs: nodejs#41677
Signed-off-by: Jimmy Leung <mingfamily@hotmail.com.hk>
@hkleungai hkleungai force-pushed the update-fsPromises-appendFile-data-type-and-test branch from 0b04ed5 to 62f79de Compare July 4, 2026 07:13
@hkleungai hkleungai changed the title doc,test: Widen fsPromises.appendFile()'s data type, add missing tests doc,test: widen fsPromises.appendFile()'s data type, add missing tests Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants