dividab / tsconfig-paths

Load node modules according to tsconfig paths, in run-time or via API.
MIT License
1.8k stars 100 forks source link

Usage together with TestCafe loses stacktrace incl. line numbers #215

Open pschmolke opened 2 years ago

pschmolke commented 2 years ago

The testing framework TestCafe by DevExpress has a standard reporter called spec (issue exists for other reporters as well) which prints additional output to the stdout, like the stacktrace with the failing line number, previous lines and preceding lines. When using tsconfig-paths/register to enable non-relative imports, the stacktrace is completly lost. Only the failing assertion is now shown, that in many cases (especially nested ones) is not very helpful.

Is there maybe some sourceMap information lost on resolving the import statements?

I register the import grammatically on the first line of the file with import tsconfig-paths/register

Output with tsconfig-paths:

 Running tests in:
 - Chrome 102.0.5005.61 / Linux 0.0

 test fixture
start test
bar
 ✖ debug

   1) AssertionError: expected true to deeply equal false

      + expected - actual

      -true
      +false

      Browser: Chrome 102.0.5005.61 / Linux 0.0

 1/1 failed (0s)

Output with relative imports:

 Running tests in:
 - Chrome 102.0.5005.61 / Linux 0.0

 test fixture
start test
 ✖ debug

   1) AssertionError: expected true to deeply equal false

      + expected - actual

      -true
      +false

      Browser: Chrome 102.0.5005.61 / Linux 0.0

          4 |fixture `test fixture`;
          5 |
          6 |test( 'debug', async ( t: TestController ) => {
          7 |   console.log( 'start test' );
          8 |
       >  9 |   await t.expect( true ).eql( false );
         10 |
         11 |   console.log( 'end test' );
         12 |} )

         at <anonymous> (/somepath-to-workspace/pschmolke/git/playground/tests/index.ts:9:27)
         at <anonymous> (/somepath-to-workspace/pschmolke/git/playground/tests/index.ts:8:71)
         at __awaiter (/somepath-to-workspace/pschmolke/git/playground/tests/index.ts:4:12)
         at <anonymous> (/somepath-to-workspace/pschmolke/git/playground/tests/index.ts:6:46)

 1/1 failed (0s)