[test optimization] Fix cypress report of typescript test files#7680
[test optimization] Fix cypress report of typescript test files#7680juan-fernandez merged 8 commits intomasterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7680 +/- ##
==========================================
+ Coverage 80.30% 80.35% +0.05%
==========================================
Files 739 741 +2
Lines 31926 32004 +78
==========================================
+ Hits 25638 25718 +80
+ Misses 6288 6286 -2 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Overall package sizeSelf size: 4.94 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.0 | 81.15 kB | 815.98 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
This comment has been minimized.
This comment has been minimized.
BenchmarksBenchmark execution time: 2026-03-09 12:22:20 Comparing candidate commit 08b42ce in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 232 metrics, 28 unstable metrics. |
b187876 to
80c22b1
Compare
…e-compiled specs When users pre-compile TypeScript spec files to JavaScript before running Cypress, TEST_SOURCE_FILE pointed to the compiled .js file instead of the original .ts file, and TEST_SOURCE_START reflected the webpack bundle line number rather than the TypeScript source line. This fix reads the adjacent .js.map source map synchronously using a custom VLQ decoder (no external dependencies), resolves the original TypeScript file path for TEST_SOURCE_FILE, and scans the compiled JS to find the test's actual line before mapping it through the source map for TEST_SOURCE_START. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
80c22b1 to
c573208
Compare
…y match
Extend source line resolution in resolveSourceLineForTest to cover
template literal test names (e.g. specify(`title ${VAR} end`, ...))
where the test name Cypress reports has the variables already evaluated
('title value end') and the source contains ${expr} placeholders.
- Add templateBodyToRegExp: converts ${expr} → .*? wildcard regex so the
evaluated test name can be matched against the source template literal
- Add Step 2b in resolveSourceLineForTest: scans the spec file for
it/test/specify calls with backtick strings and fuzzy-matches against
the runtime test name, then maps via source map as usual
- Add readSourceMap/resolveSourcePath helpers: support inline data: URI
source maps and webpack:// virtual paths in addition to adjacent .map files
- Add specify() with template literal to spec-source-line.cy.ts fixture
and extend integration tests to assert TEST_SOURCE_START=16 and
TEST_SOURCE_FILE points to the TypeScript source for both it() and specify()
- Remove DD_CYPRESS_PASSTHROUGH_PRECOMPILED_SPEC env var and the
associated getPassThroughPreprocessor() method: no bundler-specific
preprocessor needed since the name scan + source map approach works
regardless of which bundler Cypress uses
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
What does this PR do?
Improves Cypress test source-line resolution by making the fallback algorithm explicit and more robust:
invocationDetails.linefor plain JS specs without source maps.it/test/specify) and source-map mapping.invocationDetails.lineif no resolution path succeeds.Also updates comments/docs around this flow and adds deterministic regression coverage for the stack-resolution branch in
integration-tests/cypress/cypress.spec.js.Motivation
Pre-compiled/bundled TypeScript specs can report bundle-context lines in
invocationDetails.line. We need better source-line recovery while preserving fast-path behavior for plain JS and avoiding regressions in edge cases where mapping is unavailable.Additional Notes
cypress.spec.jsto cover that branch.