|
11 | 11 | * are the CJS (main) and ESM (module) outputs; the UMD <script> builds |
12 | 12 | * intentionally do NOT carry it. |
13 | 13 | * |
14 | | - * dist/ is not built by `npm test` (which is just `jest --coverage`). Locally, |
15 | | - * when the bundles are absent these tests skip with a clear message; run |
16 | | - * `npm run test:dist` to build first and assert against fresh output. Under CI |
17 | | - * (process.env.CI) missing bundles are a hard error rather than a silent skip, |
18 | | - * so the guarantee can never masquerade as a pass. Files are read as TEXT |
19 | | - * (never imported), so nothing here is pulled into coverage collection. |
| 14 | + * dist/ is not built by `npm test` (which is just `jest --coverage`), so when the |
| 15 | + * bundles are absent these tests skip with a clear message. Run `npm run test:dist` |
| 16 | + * to build first and assert against fresh output. The dedicated CI job sets |
| 17 | + * ASSERT_USE_CLIENT, under which missing bundles are a hard error rather than a |
| 18 | + * silent skip, so the guarantee can never masquerade as a pass. Files are read as |
| 19 | + * TEXT (never imported), so nothing here is pulled into coverage collection. |
20 | 20 | */ |
21 | 21 | import { existsSync, readFileSync } from 'fs'; |
22 | 22 | import { resolve } from 'path'; |
@@ -52,10 +52,13 @@ const umdBundles = ['auth0-react.js', 'auth0-react.min.js']; |
52 | 52 | const distBuilt = [...rscBundles, ...umdBundles].every((f) => existsSync(dist(f))); |
53 | 53 |
|
54 | 54 | if (!distBuilt) { |
55 | | - if (process.env.CI) { |
| 55 | + // The dedicated CI job sets ASSERT_USE_CLIENT (after building the bundles), so a |
| 56 | + // missing dist/ there is a hard error (the guarantee can never silently pass). Any |
| 57 | + // other run (e.g. `npm test`, which doesn't build) just skips. |
| 58 | + if (process.env.ASSERT_USE_CLIENT) { |
56 | 59 | throw new Error( |
57 | | - "dist/ bundles are missing but CI must assert the 'use client' directive. " + |
58 | | - 'Ensure the build runs before jest (see the `test:dist` script / rsc-directive CI job).' |
| 60 | + "dist/ bundles are missing but the 'use client' directive must be asserted. " + |
| 61 | + 'Run `npm run test:dist`, which builds the bundles before running this suite.' |
59 | 62 | ); |
60 | 63 | } |
61 | 64 | console.warn( |
|
0 commit comments