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-operations.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 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, so the flattened layout here makes it a little more
palatable.
* We also 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.
* Finally while we're moving things around, we can also move the check
we perform to ensure that the new version of a package is greater than
its existing version so that it is earlier in the entire workflow,
i.e. from building the release plan to the validating the release
specification. This also reduces the number of tests we have to write.
0 commit comments