Skip to content

fix(typescript): map included .ts files in step output - #5685

Open
luantaraschi wants to merge 1 commit into
codeceptjs:4.xfrom
luantaraschi:fix/ts-include-step-paths
Open

fix(typescript): map included .ts files in step output#5685
luantaraschi wants to merge 1 commit into
codeceptjs:4.xfrom
luantaraschi:fix/ts-include-step-paths

Conversation

@luantaraschi

Copy link
Copy Markdown

Motivation/Description of the PR

Resolves #5675.

@djyarber's observation that test files map correctly but included page objects do not comes down to two adjacent blocks in lib/container.js that do almost the same thing and disagree about where the result goes.

The helper block, around line 470, merges the transpile mapping into store.tsFileMapping. The include/support block, around line 889, merges the same shape of mapping into container.tsFileMapping only.

Step.line() in lib/step/base.js:156 reads store.tsFileMapping. So a step whose stack frame points into an included .ts module has no entry to match and keeps the .temp.mjs path, which by then has been deleted, hence the paths in the report.

Error stacks were never affected, which is why the migration guide's promise holds for failures: fixErrorStack() is handed the mapping object directly by the caller rather than reading it from store.

The include block now merges into store as well, mirroring the helper block.

Type of change

  • 🐛 Bug fix

Checklist:

  • Tests have been added
  • Documentation has been added (Run npm run docs) — N/A, no public API change
  • Lint checking (Run npm run lint)
  • Local tests are passed (Run npm test)

I want to be straight about the missing test. Exercising this needs a container built from a config with a TypeScript include, transpiled for real, and I did not get a harness for that working that I would trust. test/unit/utils/typescript_test.js drives transpileTypeScript directly and never touches the container. A test asserting Step.line() maps a path when store.tsFileMapping already holds the entry would pass before and after this change, so it would prove nothing.

What I did verify is the asymmetry itself: both blocks receive the same mapping from transpileTypeScript, only one writes to store, and store is what the reader uses. If you point me at the right fixture or harness for a config-level include I will add the regression test.

Unit suite on Windows: 758 passing / 11 failing, unchanged by this PR. Those 11 are pre-existing path assertions that expect POSIX paths and see a C: drive letter (utils_test.js, utils/trace_test.js).

Two adjacent blocks in container.js merge a transpile mapping after
compiling TypeScript. The helper block merges into store.tsFileMapping;
the include/support block merges only into container.tsFileMapping.

Step.line() reads store.tsFileMapping, so a step whose stack frame points
into an included page object had no entry to match and was printed with
the deleted .temp.mjs sibling instead of the .ts source. Error stacks were
unaffected because fixErrorStack() is handed the mapping directly.

The include block now merges into store as well, mirroring the helper
block two hundred lines above it.

Closes codeceptjs#5675
Copilot AI lite review requested due to automatic review settings August 7, 2026 12:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scenario Steps show .temp.mjs instead of .ts for TypeScript include modules

2 participants