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

[code-infra] Package test utils #41177

Merged
merged 20 commits into from
May 29, 2024
Merged

Conversation

michaldudak
Copy link
Member

@michaldudak michaldudak commented Feb 19, 2024

Renames the @mui-internal/test-utils to @mui/internal-test-utils and prepares the package to be published to npm.

@michaldudak michaldudak added the scope: code-infra Specific to the core-infra product label Feb 19, 2024
@mui-bot
Copy link

mui-bot commented Feb 19, 2024

Netlify deploy preview

https://deploy-preview-41177--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against 21c6da3

@michaldudak michaldudak requested a review from a team February 19, 2024 12:25
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 20, 2024
@github-actions github-actions bot added PR: out-of-date The pull request has merge conflicts and can't be merged and removed PR: out-of-date The pull request has merge conflicts and can't be merged labels Feb 20, 2024
@michaldudak michaldudak marked this pull request as ready for review February 21, 2024 14:58
@github-actions github-actions bot added PR: out-of-date The pull request has merge conflicts and can't be merged and removed PR: out-of-date The pull request has merge conflicts and can't be merged labels Feb 21, 2024
Copy link
Member

@Janpot Janpot left a comment

Choose a reason for hiding this comment

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

Do we need to find more consensus cross team before fully committing to nx as a build tool?

@michaldudak
Copy link
Member Author

Isn't it just a Core repo problem? If other repos use built packages from npm, we can still rely on pnpm. Or is there something more in the other repos that could benefit from a more advanced orchestrator?

@Janpot
Copy link
Member

Janpot commented Feb 28, 2024

I'm just mentioning because I remember this coming up before with the X team in https://www.notion.so/mui-org/code-infra-Introduce-align-on-a-task-runner-ee2765d98ae74ec2bf9dca9b88a3561a#4356019bcc8e4900849fa1156eb7630d
The only thing I want to avoid is X and core using a different one.

@michaldudak michaldudak changed the base branch from master to next April 23, 2024 08:18
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 23, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 27, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 27, 2024
@michaldudak michaldudak force-pushed the package-test-utils branch from bfe2f41 to 2144496 Compare May 27, 2024 09:53
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 27, 2024
@michaldudak michaldudak force-pushed the package-test-utils branch from fc4fc4e to f2aba3b Compare May 27, 2024 15:00
package.json Outdated
"test:e2e:server": "serve test/e2e -p 5001",
"test:e2e-website": "playwright test test/e2e-website --config test/e2e-website/playwright.config.ts",
"test:e2e-website:dev": "cross-env PLAYWRIGHT_TEST_BASE_URL=http://localhost:3000 playwright test test/e2e-website --config test/e2e-website/playwright.config.ts",
"test:karma": "cross-env NODE_ENV=test karma start test/karma.conf.js",
"test:karma:profile": "cross-env NODE_ENV=test karma start test/karma.conf.profile.js",
"test:karma": "pnpm nx run nx_test_karma",
Copy link
Member

@Janpot Janpot May 28, 2024

Choose a reason for hiding this comment

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

Is running nx through pnpm necessary here? In some commands it's running like this, In some other commands nx is run directly

Suggested change
"test:karma": "pnpm nx run nx_test_karma",
"test:karma": "nx run nx_test_karma",

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 nx run is sufficient indeed.

Copy link
Member

@Janpot Janpot left a comment

Choose a reason for hiding this comment

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

Looks good, hope I didn't miss anything scrolling through those renames 🙂
I added one question, no blocker.
After we merge this, I suppose we'd do the same for @mui-internal/api-docs-builder?

@michaldudak
Copy link
Member Author

michaldudak commented May 28, 2024

Yes, the API docs builder is next. It can be included in @mui/internal-scripts.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 28, 2024
@michaldudak michaldudak merged commit 213b5e3 into mui:next May 29, 2024
22 checks passed
@michaldudak michaldudak deleted the package-test-utils branch May 29, 2024 08:25
@DiegoAndai
Copy link
Member

@michaldudak thanks for this! Question: Previously, I was running unit tests with the --watch flag (pnpm test:unit --watch) to watch file changes. After this update, the --watch flag seems to be bugged: It does rerun tests after file changes, but the file changes are not taken into account. Is this expected? Is there a new way to watch changes?

@michaldudak
Copy link
Member Author

I'm not aware of anything that could cause such an issue. I'll investigate.

@michaldudak
Copy link
Member Author

One issue I found (and fixed): #42519
Let me know if it helps.

@DiegoAndai
Copy link
Member

DiegoAndai commented Jun 4, 2024

I tested again both on your PR and the next branch, and --watch is working as expected on both 😅
I'm not sure what happened the other day.
Thanks!

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 8, 2024

I have found a regression from this PR in HEAD, while I was trying to run a test. It crashes now:

  1. Start from a clean state, git rm -rf . && git clean -fxd && git reset --hard && pnpm i
  2. Run pnpm tc useControlled
SCR-20240608-lixd

vs. the commit just before:

SCR-20240608-ljkl

@DiegoAndai I almost never use pnpm test:unit --watch because I find it way too slow to run, especially when I switch between 20 PRs a day.

A side observation: I might sound like a broken record, but I'm still unable to see the net benefit of building the dependencies of test utils internal in http://github.com/mui/material-ui vs. consuming straight from the source. For a Pigment CSS dependency written in Rust, yes, OK: a higher fidelity npm publish experience feels more valuable, especially if nothing else downstream uses Rust.
But here it feels like we trade a slower test DX (on HEAD, it in my test, it took 10.13s to run on cache miss and 6.89s on cache hit vs. on 384e5e4 it took 4.49s for pnpm tc useControlled to run, no cache) and a more complex build setup (have to care about caching and correct build interdependencies vs. we have to pay the cost of build fidelity in any cases for the public packages since it would be an impossible DX for maintainers/contributors to build them for each change to try them on the docs or tests) in exchange for a higher fidelity npm publish experience.

Opened #42572 to restore HEAD in a working state.

joserodolfofreitas pushed a commit to joserodolfofreitas/material-ui that referenced this pull request Jul 29, 2024
@michaldudak
Copy link
Member Author

I'm still unable to see the net benefit of building the dependencies of test utils internal in http://github.com/mui/material-ui vs. consuming straight from the source.

This ensures that the code in this repo uses the same implementation of test-utils as other repos (for example making sure it doesn't use something that's not exported in the release build).
The test-utils (as the rest of the shared infra code should be moved out of this repo and referenced through npm by Material UI. This will make it even faster than the implementation before this PR (no need to transpile TS anymore).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: code-infra Specific to the core-infra product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants