OpenFn / kit

The bits & pieces that make OpenFn work. (diagrammer, cli, compiler, runtime, runtime manager, logger, etc.)
12 stars 11 forks source link

node 20: mock-fs breaks #834

Open josephjclark opened 1 day ago

josephjclark commented 1 day ago

When updating to node 20, mock-fs breaks.

We use mock-fs extensively in unit tests to load fake adaptor files and such. Bumping the mock-fs version helps, but we also have a problem dynamically importing modues.

Basically mock-fs will only mock the filesystem for node:fs. When using import() (as we do in the runtime to load adaptors), the file system isn't mocked out at all.

josephjclark commented 1 day ago

Notes on the problem form @doc-han 👍

  1. readFileSync Issue: https://github.com/tschaub/mock-fs/issues/377 (fixed via a version bump to 5)

  2. don't see a good issue around mock-fs not working with dynamic import in node v20. closest issue for mock-fs@v3https://github.com/tschaub/mock-fs/issues/130

Our only failing tests are in packages/cli/test/commands.test.ts

josephjclark commented 1 day ago

I think we need to look for a different solution to commands.test.ts. The options as I see it right now:

  1. Remove CLI tests that use the file system for adaptors
  2. Actually use the file system for adaptors (maybe with a helper librry ot support us). As in - don't mock modules, but actually create them. We do actually do this in many tests today IIRC.
  3. Remove the failing tests entirely. At the time of writing I don't know how valuable these tests are - but this is unlikely to be my preferred choice!