Closed TimKnight-DWP closed 10 months ago
Right, yes. This is to do with mock-fs, which doesn’t support later versions of node (see https://github.com/tschaub/mock-fs/issues/377 )
If you want to test with node 20, you currently need to pin to node 20.4.
Longer term I’m a little concerned about code rot in the test dependencies - many of them are not maintained any more, and might not work moving forward to newer versions of node.
I’m not really sure what the best strategy is. I’d like to update/ modernise the tests without dropping the features that are covered, but it may be challenging or need a great deal of care
Agreed - it's a robust set of tests but the mocking process is quite complex, we'd need to figure out a better solution for injecting test CHANGELOGs etc which may or may not be Fs mocking in some capacity
I'm going to propose to our teams that we spend some time in the next Agile cycle looking at this, since we make heavy use of commit-and-tag-version in our release cycles across the company. Will come back to you if we have time to dedicate to cracking this or not 👍
I'm going to pick this up and attempt a re-work of the tests 👍
Thank you! Apologies for the silence, I've been off sick.
If it helps, I think running the tests with typescript would be a great first step on migrating to typescript (the other efforts stalled when they couldn't run the tests) - but don't feel the need to attempt it if it blows out or hinders your rework.
I think I am going to start by converting the tests from mocha
to jest
as that gives access to spies and should be step 1. of being able to replace mock-fs
with a jest implementation.
And then I'll go from there
Sounds great. I'll merge the formatter change now, so you can get started from a prettier base.
Making good progress over 2 days 😅 , having to remove all the mockery, std-mocks as well, but it should be a cleaner package tree. There's probably a follow up piece to re-work some of the tests and production code layout to make mocking/spying on read/write to Fs easier now that moving off mock-fs
loses us access to it's in memory mocking of the File system
But. So far so good, 3 tests left in core.spec
to get passing and that's the bulk of the tests done
Thanks for the update! Much appreciated!
I've converted the tests now, but currentgly having some problems with my local config when running the more "integration" style tests, especially the git stuff has a nightmare with me using pre-commit widely.
I'll push it up, so we can see what happens in the GitHub action, and I'll keep working on it in the meantime
Describe the bug When using Node 20.9.0 the unit tests do not run successfully When using Node 18.16.0, the unit tests complete fine
Current behavior When running the tests in CLI or through an IDE with Node 20.9.0 as the runtime, it deletes the contents of
package.json
andCHANGELOG.md
and therefore halfway through the test there is no package.json so the runtime immediately falls overExpected behavior Tests should pass and the unit tests should be usiing the mocked CHANGELOGs etc rather than the real ones sat in the Repo
Environment
commit-and-tag-version
version(s): LatestPossible Solution
I suspect it will be related to the test-runner and Fs changes in node20: https://nodejs.org/en/blog/announcements/v20-release-announce#stable-test-runner
Commit-and-tag-version itself runs fine and as expected using Node 20, but we cannot maintain/run tests when using Node 20 as the runtime (at least locally)
Additional context Add any other context about the problem here. Or a screenshot if applicable