Skip to content

Report does not contain a reference to the location of the test when using macros or helpers from another file #2722

Open
@MatthiasKunnen

Description

@MatthiasKunnen

When using a macro, the failure report does not include a line number that could be used to navigate to the test.

Example of the report:

  Number must be 5

  Difference:

  - 4
  + 5

  › macro (typescript/helper/macro.ts:4:7)

Reproduction: https://github.com/MatthiasKunnen/ava-line-number-reproduction.
AVA version: 3.15.0.
AVA configuration: See repo.

Proposal
Capture the line number when test is invoked and either add it to the stack trace or add it above the diff, e.g. typescript/spec/something.spec.ts:7

Notes
Interestingly, the report is a bit different when the macro is inside vs outside the spec file. This can be seen on the root commit in the reproduction repository. Example diff with the + side representing a macro outside the spec file:

Number must be 5

-typescript/spec/something.spec.ts:4

-3: const macro: Macro<[number]> = (t, number) => {
-4:     t.is(number, 5);                           
-5: }

Difference:

﹣ 4
﹢ 5

-› macro (typescript/spec/something.spec.ts:4:7)
+› macro (typescript/helper/macro.ts:4:7)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions