Scenario Steps report wrong line/column for TypeScript include modules

Ouverte
#5,772 0 commentaires 1 réaction 2 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

@kobenguyent y travaille déjà.

Depuis le 31/10/2026.

  • #5776 par @copilot-swe-agent — fermée sans fusion
  • #5782 par @azdemir — ouverte

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
72/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
node.js, typescript
Domaine
testing

Piste de recherche

Start by reading the code that rewrites .temp.mjs paths for Scenario Steps and the sandbox runner tests mentioned in the issue. Reproduce with the supplied TypeScript include example, then add a test asserting I.doThing points to fooPage.ts:6:5 while the test-file step remains correct. Done when reported source line and column match the TypeScript file.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Scenario Steps report wrong line/column for TypeScript include modules (after path fix)

Summary

After #5685 (current releases / latest on npm), Scenario Steps for TypeScript include modules show the correct .ts path, but line/column still come from the transpiled .temp.mjs, not the source file. Steps in test files report correct lines.

Related: #5675 (closed), #5685 (merged).

Expected vs actual

pages/fooPage.ts — I.doThing is on line 6:

Expected: ✔ I.doThing("...") at Object.open (./pages/fooPage.ts:6:5)
Actual:   ✔ I.doThing("...") at Object.open (./pages/fooPage.ts:4:11)

In the same scenario, the test-file step is the control (correct line):

✖ I.failNow("deliberate failure so Scenario Steps is printed") at Test.<anonymous> (./tests/fooTest.ts:5:5)

Repro (browser-free)

codecept.conf.js:

export const config = {
  tests: './tests/fooTest.ts',
  output: './output',
  helpers: {
    FakeHelper: { require: './fakeHelper.js' },
  },
  include: { fooPage: './pages/fooPage.ts' },
  require: ['tsx/cjs'],
  name: 'ts-step-paths-repro',
};

fakeHelper.js:

import Helper from 'codeceptjs/lib/helper';

export default class FakeHelper extends Helper {
  doThing(label) {
    return label;
  }

  failNow(message) {
    throw new Error(message);
  }
}

pages/fooPage.ts:

export {};
const { I } = inject();

export default {
  open() {
    I.doThing('called from a .ts page object under include');
  },
};

tests/fooTest.ts:

Feature('ts step paths');

Scenario('reports page object step path', ({ I, fooPage }) => {
  fooPage.open();
  I.failNow('deliberate failure so Scenario Steps is printed');
});
cd <repro-directory>
npm install codeceptjs@latest tsx typescript
npx codeceptjs run -c codecept.conf.js

Install codeceptjs, tsx, and typescript in one command. Check Scenario Steps for the I.doThing line.

Location Expected (source) Reported (latest)
I.doThing in pages/fooPage.ts ./pages/fooPage.ts:6:5 ./pages/fooPage.ts:4:11
I.failNow in tests/fooTest.ts ./tests/fooTest.ts:5:5 ./tests/fooTest.ts:5:5 ✓

Environment

  • CodeceptJS latest on npm (reproduced on 4.2.2)
  • Node 26.x, macOS
  • require: ['tsx/cjs']

Suggested fix

Remap line/column when rewriting .temp.mjs → .ts (source maps or equivalent), and add a sandbox runner test that asserts source line/col for an included page object step.

Langage dominant
JavaScript
Étoiles
4.2k
Forks
754
Merge moyen
2 j 6 h
PR mergées (30 j)
33

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de codeceptjs/CodeceptJS

Toutes les issues de codeceptjs/CodeceptJS

Issues similaires

Plus d'issues JavaScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.