You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tests for `monorepo-workflow-utils.ts` are not as readable or
maintainable as I'd like them to be. This commit attempts to fix that:
* While there isn't a whole lot we can do in terms of the scenarios
we're testing because the function makes a lot of calls and the logic
inside of it is somewhat complicated, we can at least move
code that is responsible for parsing the TODAY environment variable,
building a ReleasePlan object from the release spec, and applying the
updates to the repos themselves out into separate files. This
simplifies the test data and removes a few tests entirely.
* We can also simplify how `planRelease` (one of the things we moved
out) works so that instead of checking whether the
version-to-be-released for a package is the same as the package's
current version there, we can check for that in
`validateReleaseSpecification`.
* We also simplify the structure of the tests so that we aren't using so
many nested `describe` blocks. This ends up being very difficult to
keep straight in one's head, so the flattened layout here makes it a
little more palatable.
* Finally, we simplify the setup code for each test. Currently we are
mocking all of the dependencies for `followMonorepoWorkflow` in one
go, but we're doing so in a way that forces the reader to wade through
a bunch of type definitions. That isn't really that helpful. The most
complicated part of reading the tests for `followMonorepoWorkflow`
isn't the dependencies — it's the logic. So we take all of the
decision points we have to make in the implementation and represent
those as options to our setup function in the tests so it's as clear
as possible which exact scenario is being tested just by reading the
test.
0 commit comments