avajs/ava
View on GitHubReport does not contain a reference to the location of the test when using macros or helpers from another file
Open
#2722 opened on Mar 20, 2021
help wantedscope:assertionsscope:reporters
Description
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)