nodejs / corepack

Zero-runtime-dependency package acting as bridge between Node projects and their package managers
MIT License
2.31k stars 145 forks source link

Remove nock database #494

Open mcollina opened 3 weeks ago

mcollina commented 3 weeks ago

Having a "nock" database makes this codebase harder to reason about due to the "dynamic" nature of this mocking.

Can this be refactored out?

aduh95 commented 3 weeks ago

Can you clarify what's "dynamic" about it? Note that you need to provide NOCK_ENV=replay env variable, otherwise the nock DB is ignored.

mcollina commented 3 weeks ago

Maybe I don't understand the source code exactly, but https://github.com/nodejs/corepack/blob/main/.github/workflows/update-nock-files.yml updates it in a PR id passed through. Maybe dynamic is not the right term, but I found this quite hard to reason about.

Why would you need this step?

aduh95 commented 3 weeks ago

If we remove it, it’s only going to make the CI more flaky – because tests would rely on network calls instead of the FS. The only thing dynamic about it is that changes in Corepack internals can result in different endpoint being hit, at which point the nock db needs to be updated to cover those new endpoints.

Why do we need the workflow: I use it because I find it simpler to use it than to pull the PR branch locally and update the nock DB manually.