Repository navigation
test(mcp): build both targets inside test so a stale dist cannot pass - #10
Conversation
The tests run the built artifacts (dist/server/index.js, dist/view.html and the Workers bundle), but `pnpm mcp test` ran them without building. With a source change and an old dist/, every test passed against the old build: with src/node/index.ts throwing on import, the old command passed 154/154, and the new one fails. `test` now runs build and build:worker first. Turbo's test task drops its separate build dependencies, and `verify` drops its build steps, so nothing builds twice. test:browser now runs after test, and test declares dist/ and dist-worker/ as outputs, so one Turbo run never builds in two tasks at once and a cache hit restores the build. Answers ansari#335 Q5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yia-mw-agent
left a comment
There was a problem hiding this comment.
Reviewed the full merge-base-to-head diff (base develop 396b091 = merge-base, 3 files) at 69dba4e. No material defects.
Helmet-Review-Request: #10 (comment)
What I checked:
- apps/mcp/package.json:
testnow runsbuildandbuild:workerbefore the tests, andverifydrops its own build steps, so each target is built once. The roottestscript excludes ansari-mcp, so no other job is affected. - apps/mcp/turbo.json:
testdrops its build dependencies and declaresdist/**anddist-worker/**as outputs;test:browserdepends ontest. This avoids two Turbo tasks building at once and lets a cache hit restore the build. - apps/mcp/README.md matches the new behaviour.
Validation at this exact head (apps/mcp): lint and typecheck pass; pnpm test rebuilt both targets and passed 154/154; test:browser passed 78 checks with no errors. Under Turbo (turbo run test test:browser --filter ansari-mcp --env-mode=loose): test ran, then test:browser passed. After moving dist/ and dist-worker/ aside, turbo run test:browser showed test as a cache hit that restored both directories, and the 78 checks passed. This matches the PR description. CI checks (MCP application, api, auth, frontend, gitleaks) are green. Live head matched 69dba4e at start and before submission.
Non-blocking: under Turbo's default strict env mode, test:browser does not see PLAYWRIGHT_BROWSERS_PATH. That only mattered in my sandbox (a non-default browser cache) and is unchanged by this PR.
Answers Q5 of iaser-ai#335.
What was wrong
The MCP tests run the built artifacts:
dist/server/index.js,dist/view.htmland the Workers bundle.pnpm mcp testran them without building, so after a source change they passed against the old build.Shown on this branch before the change: I built, then made
src/node/index.tsthrow on import. The oldpnpm testpassed all 154 tests. The new one rebuilds and fails on the thrown error.Change
testrunsbuildandbuild:workerbefore the tests.verifyno longer runs its own build steps, so it builds each target once.In
apps/mcp/turbo.json:testdrops itsbuildandbuild:workerdependencies, and declaresdist/**anddist-worker/**as its outputs.test:browsernow depends ontestinstead ofbuild.Together these keep a single Turbo run from building in two tasks at once, and let a cache hit on
testrestore the build thattest:browserreads.The README says
testbuilds first and thattest:browserreads the build without making one.No version bump: this changes only test wiring and docs.
Verification
pnpm mcp verifypassed: 154 tests and 78 browser checks. Each target was built once.turbo run test test:browser --filter ansari-mcp --forcerantest, thentest:browser, and both passed.dist/anddist-worker/and ranturbo run test:browser.testwas a cache hit that restored the build, and the 78 browser checks passed.pnpm mcp test:browserrun on its own still reads whatever is indist/. That is unchanged and documented.🤖 Generated with Claude Code