-
-
Notifications
You must be signed in to change notification settings - Fork 5
Add functional tests #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
30abbd6
to
120a622
Compare
This commit adds tests which run the script within a separate shell instance and verifies that the script makes the appropriate changes to the repo. I've tried to make these functional tests as readable as possible. In order to do that, I created a small framework which replicates the environment in which the script will run and then allows that environment to be modified per-test to suit the assertions being made.
120a622
to
e23c2e2
Compare
* @param error - The object to check. | ||
* @returns True or false, depending on the result. | ||
*/ | ||
export function isErrorWithCode(error: unknown): error is { code: string } { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll notice that some of these helpers are repeated from misc-utils
. I could have reused them, but it feels a little off to me to reuse implementation code in test code, even if it's the exact same code. Ideally, I think, we could move this to @metamask/action-utils
or even @metamask/utils
and then I think I'd feel better about it.
|
||
describe('create-release-branch (functional)', () => { | ||
describe('against a monorepo with independent versions', () => { | ||
it('updates the version of the root package to be the current date along with the versions of the specified packages', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm only testing the happy paths right now. This file is going to grow larger as we add different features — for instance, right now there is no logic around changed packages, so once that happens we need to consider what happens when the repo has no tags, etc. — so I'm hesitant to add error/alternate cases. I figure it's easier to add more test cases later than remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! The test helpers here are... extensive, but the way it's structured all made sense to me. It might have been easier to use plain file fixtures instead for the workspace/repo generation parts, but I can see some advantages to this way too.
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This commit adds tests which run the script within a separate shell
instance and verifies that the script makes the appropriate changes to
the repo.
I've tried to make these functional tests as readable as possible. In
order to do that, I created a small framework which replicates the
environment in which the script will run and then allows that
environment to be modified per-test to suit the assertions being made.