material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[code-infra] Package test utils

Open michaldudak opened this issue 1 year ago • 3 comments

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

michaldudak avatar Feb 19 '24 11:02 michaldudak

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 :no_entry_sign: dangerJS against 21c6da37ca0fc6f9a517785d479a89f6e2337c29

mui-bot avatar Feb 19 '24 11:02 mui-bot

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?

michaldudak avatar Feb 28 '24 12:02 michaldudak

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.

Janpot avatar Feb 28 '24 13:02 Janpot

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

michaldudak avatar May 28 '24 09:05 michaldudak

@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?

DiegoAndai avatar May 30 '24 16:05 DiegoAndai

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

michaldudak avatar Jun 04 '24 08:06 michaldudak

One issue I found (and fixed): https://github.com/mui/material-ui/pull/42519 Let me know if it helps.

michaldudak avatar Jun 04 '24 08:06 michaldudak

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!

DiegoAndai avatar Jun 04 '24 19:06 DiegoAndai

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 384e5e4158 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 https://github.com/mui/material-ui/pull/42572 to restore HEAD in a working state.

oliviertassinari avatar Jun 08 '24 10:06 oliviertassinari