Commit dbe1fa7
fix(tests): fix e2e sleep (#10061)
* fix(tests): wait for registry readiness in global setup instead of per-test sleep
The first e2e test was flaky on CI because `start-server-and-test` only
checks that the root URL (http://localhost:4000) responds before running
tests, not the /r registry endpoint. The existing 2-second hardcoded sleep
in the first test was unreliable on slower CI runners.
Move the readiness check into the vitest globalSetup so all tests wait for
the registry /r endpoint to actually be reachable before any test starts.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(tests): fix race condition in global setup - poll correct URL and CLI binary
Two issues caused the previous fix to fail:
1. Was polling `http://localhost:4000/r` which is a directory → always 404.
Now polls `{REGISTRY_URL}/index.json`, a real static file that returns 200.
2. The v4 dev script (`pnpm --filter=shadcn build && pnpm icons:dev & next dev`)
runs the shadcn CLI build in the background while next dev starts immediately.
On fast CI runs start-server-and-test can detect the server as ready before
the CLI binary (packages/shadcn/dist/index.js) has been built, causing the
first test to fail when it tries to invoke the CLI.
Now explicitly waits for the binary to exist before any test runs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(tests): warm up /init route in global setup to prevent first-test timeout
The CLI's first request during `shadcn init` hits the dynamic Next.js /init
route. On a cold dev server this route takes ~1.8s to compile. Combined with
the rest of what init does (pnpm install, file writes), this pushes the first
test over the 30s CLI timeout on CI. Subsequent tests pass because the route
is already warm.
Polling /init in global setup ensures the route is compiled before any test
runs, making the first test's CLI invocation as fast as all subsequent ones.
Also replaced the /r/index.json poll (a static file that responds immediately
and doesn't reflect real route readiness) with the actual /init route poll,
which also naturally verifies the registry server is up.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(tests): warm up 404 route and increase default CLI timeout
Two more issues found in CI logs:
1. The CLI requests font files that don't exist (e.g. /r/styles/new-york-v4/
font-geist.json), causing Next.js to compile /_not-found/page on the first
404 response. That compilation takes ~4-5s on a cold dev server and is
another hidden cost on the first test. Now triggering a 404 in global setup
so the not-found page is compiled before any test runs.
2. The default CLI timeout of 30s is too tight for CI. Even with the /init and
404 routes pre-warmed, pnpm install inside the fixture takes ~25s, leaving
only ~5s of headroom. Increasing the default from 30s to 60s gives a
comfortable buffer without masking real hangs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 74c4c75 commit dbe1fa7
File tree
3 files changed
+51
-4
lines changed- packages/tests/src
- tests
- utils
3 files changed
+51
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | 15 | | |
19 | 16 | | |
20 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
7 | 22 | | |
8 | 23 | | |
9 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
10 | 60 | | |
11 | 61 | | |
12 | 62 | | |
| |||
0 commit comments