Skip to content
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

Selective test on workspace name with the --package option #2145

Merged
merged 8 commits into from
Sep 20, 2022

Conversation

cristiano-belloni
Copy link
Contributor

@cristiano-belloni cristiano-belloni commented Sep 14, 2022

Enhance modular test with the following behaviour:

$ modular test --package PACKAGE_NAME
# Run all tests for PACKAGE_NAME

$ modular test --package PACKAGE_NAME_1 --package PACKAGE_NAME_2
# Run all tests for PACKAGE_NAME_1 and PACKAGE_NAME_2

$ modular test --package PACKAGE_NAME --ancestors
# Run all tests for PACKAGE_NAME and all other workspaces that, directly or indirectly, depend on it

$ modular test --package PACKAGE_NAME --changed
# Options are not compatible: exit with error

modular test SOME_REGEX --package PACKAGE_NAME
# Options are not compatible: exit with error

@changeset-bot
Copy link

changeset-bot bot commented Sep 14, 2022

🦋 Changeset detected

Latest commit: 0111c22

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
modular-scripts Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coveralls
Copy link
Collaborator

coveralls commented Sep 15, 2022

Coverage Status

Coverage decreased (-0.2%) to 33.195% when pulling 0111c22 on feature/single-package-test into deaee2c on main.

@cristiano-belloni cristiano-belloni marked this pull request as ready for review September 16, 2022 12:46
docs/commands/test.md Outdated Show resolved Hide resolved
Default: `undefined`

Run all the test for the workspace with the specified package name. Can be
repeated to select more than one workspace. Can be combined with the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a typo?

Suggested change
repeated to select more than one workspace. Can be combined with the
repeated to select more than one package. Can be combined with the

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not. I'm confused - are they workspaces or packages? In my mind, a workspace can consist of many packages (the workspace usually means the packages dir, if talking in yarn languge)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's incredibly confusing, but it seems that any package that falls in the workspaces glob / array in the manifest is called a "workspace": https://classic.yarnpkg.com/lang/en/docs/workspaces/

randomOutputFolder,
['test', '--ancestors', '--package', 'b', '--package', 'c'],
);
expect(resultPackagesWithAncestors.stderr).toContain(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could maybe use a single expect statement here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmmh, not sure what you mean - it's not possible to pass an array to toContain and it's not possible to chain expectations, how would you use a single expect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you're saying that we can conflate packages/c/src/__tests__/utils/c-nested.test.ts and packages/c/src/__tests__/utils/c-nested.test.ts into their common root: packages/c/src/__tests__/; in that case I explicitly wanted to show that we're executing all the tests of a workspace, including those in subdirectories.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the shape of resultPackagesWithAncestors.stderr? I can imagine we can find a way to dedupe this a bit, but it's really not a big deal

Co-authored-by: Sam Brown <sam.brown@jpmorgan.com>
@cristiano-belloni cristiano-belloni merged commit a17e9df into main Sep 20, 2022
@cristiano-belloni cristiano-belloni deleted the feature/single-package-test branch September 20, 2022 11:24
This was referenced Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants