-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix tests on node 20 #387
Fix tests on node 20 #387
Conversation
Both `fs.promises.open().then(fh => fh.write()` and `fs.openSync().write()` call write without a callback, but fs.promises must return a Promise, while openSync must not. I added _isPromise to the descriptor so we can return the right type for the handle open was called with. This doesn't feel right, but I couldn't figure out a different way to call it.
Node 20 seems to change changed `atime` ect to be a non enumerable property, so `stats.hasOwnProperty('atime')` is false, and `Object.assign({}, stats)` doesn't copy atime. I updated the file and directory creation to handle either atime, or atimeMs fields, and updated a test to compare either.
Thanks, @everett1992! Could you add mock-fs/.github/workflows/test.yml Lines 26 to 28 in b0808c5
And then the readme can be updated here: Line 273 in ea6e334
It looks like tests also pass on Node 22. If you find the same, we could add 22 to the list as well. |
Oh, I forgot about all the ignored tests. So not right to imply that all "tests pass" on Node 20 and 22. Do you know if there are tests that are currently ignored that would pass with your changes? |
Doesn't look like I fixed any of those
|
I think those disabled mock.fs tests should be removed, since mock.fs was removed in v4
https://github.com/tschaub/mock-fs/blob/main/changelog.md#400 |
Thanks for the reminder! Those tests could have been removed instead of ignored in https://github.com/tschaub/mock-fs/pull/182/files#diff-e78e0b8d4a6016fffbd3160920548d5860afed84b611d22f4f6e0c42609d7ce6. |
Thank you @everett1992 and @andrewnicols! |
This includes @andrewnicols's changes from #381
All unit tests pass on node 20 (and 22)
I have not written any new tests, or checked that any new APIs work correctly.
This at-least partially fixes #384. I tested these changes in an application that was failing with mock-fs 5.2.0 and node 20