## Summary
CI picks which tests to run on a PR by building a module graph of the
repo and walking it backwards from the changed files. That graph is
built by madge, which resolves imports through enhanced-resolve using
`scripts/madge.webpack.config.cjs`.
That config had no `extensionAlias`. Packages written for TypeScript's
NodeNext resolution import their own relative files as `'../tools.js'`
even though the file on disk is `../tools.ts` — and without
`extensionAlias` the resolver looks for a literal `.js` file, finds
nothing, and silently drops the edge. `mastracode/sdk` is written
entirely in that style (212 of 256 source files), so its portion of the
graph was essentially empty and any PR touching SDK source was told no
tests were affected. The full-suite jobs did not catch this either, so
those changes shipped with no test signal at all.
Two changes: teach the resolver to map `.js`/`.mjs`/`.cjs` specifiers
onto their TypeScript sources, and let madge traverse `.mts`/`.cts`
files, which this package uses for its child-process fixtures.
Fixes#24218
## Test plan
Detector output for the same inputs, before and after:
| changed file | before | after |
| --- | --- | --- |
| `mastracode/sdk/src/agent-connections/tools.ts` | 0 tests | 20 tests,
including its own colocated `__tests__/tools.test.ts` |
| `mastracode/sdk/src/index.ts` | 0 tests | 19 tests |
| `packages/core/src/agent/index.ts` (control) | 1229 tests | 1470 tests
|
The control case was already working but was also under-selecting, since
workspace packages consumed by core use the same import style; it now
resolves those edges too.
Graph is denser, so selection is slightly slower — 21.4s to 23.5s for
the core case, about 10%. That is well worth the correctness.
Note: registering the SDK's own vitest project is separate work, as the
issue describes — `vitest.config.ts` points at a
`mastracode/vitest.config.ts` that does not exist, and the SDK suite is
currently red on main. This PR only fixes the detector.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## ELI5
This PR helps the test selector follow SDK imports correctly. It ensures
source changes select the tests that depend on them.
## Changes
- Added Madge aliases for `.js`, `.mjs`, and `.cjs` imports.
- Added `.mts` and `.cts` files to Madge traversal.
- Added a NodeNext import-resolution test.
- Added a guard for missing colocated tests.
- Added two retries for failed TUI E2E shard tests.
## Reported results
- SDK tool changes select 20 tests instead of none.
- SDK index changes select 19 tests instead of none.
- A core control case selects 1,470 tests, up from 1,229.
- Runtime increased from 21.4 to 23.5 seconds.
- SDK Vitest project registration remains out of scope.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: tyler-mastra[bot] <331730378+tyler-mastra[bot]@users.noreply.github.com>
Co-authored-by: Tyler Barnes <tylerdbarnes@gmail.com>
Before, `@mastra/server/server-adapter` was resolved as if it lived
directly under `packages/server/src`, so affected-test selection skipped
adapter coverage.
This now follows workspace export paths back to source modules, so
server handler changes select dependent adapter tests. For the workflow
change from #20184, the analyzer now includes 9 Express and 11 Fastify
tests.
I checked formatting and graph resolution, then ran the affected-test
analyzer. Running the Express suite now reaches the existing 409
expectation failures that this CI gap had hidden.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## ELI5
The test tool now follows workspace package links to the real source
files. It selects tests that depend on changed server handlers,
including 9 Express tests and 11 Fastify tests.
## Changes
- Added `buildWorkspaceSourceAliases` in
`scripts/workspace-source-aliases.cjs`.
- Reused shared workspace alias logic in affected-test analysis and
Madge Webpack configuration.
- Added support for workspace export subpaths and exact aliases.
- Removed duplicated package discovery and alias construction logic.
- The Express suite now exposes existing 409 expectation failures that
CI previously missed.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>