hbenl / vscode-mocha-test-adapter

Mocha Test Adapter for the VS Code Test Explorer
MIT License
91 stars 31 forks source link

`ts-node` 8.10 puts CodeLens run commands in the wrong place #111

Closed sgranade closed 4 years ago

sgranade commented 4 years ago

I recently upgraded ts-node from 8.9.1 to 8.10.0 in my project. When I did that, CodeLens started putting the run commands in the entirely wrong places.

With ts-node 8.9.1, the CodeLens run locations are correct: 8 9_corrent_codelens

However, if I upgrade ts-node to 8.10.0 or 8.10.1, then the CodeLens run locations are wrong.

8 10_incorrect_codelens

The tests appear to run correctly, but I can't tell what CodeLens "run" command goes with which test, and test failures are attached to the entirely wrong line.

8 10_incorrect_test_result_location

Any idea what might be going on?

hbenl commented 4 years ago

I'm guessing it is due to TypeStrong/ts-node#1055 for which they already have a fix, but it hasn't been published yet. In the meantime you could try adding "mochaExplorer.monkeyPatch": false to your settings: this will switch to a more primitive mechanism for detecting the test locations. The standard mechanism uses stack traces to find the locations and those stack traces seem to have wrong line numbers due to the ts-node bug.

hbenl commented 4 years ago

The issue was fixed in ts-node 8.10.2.

pcnova commented 2 years ago

Just want to note that this issue also happens in later versions (mine is 9.1.1) if you happen to be using the ts-node/esm loader.

Setting "mochaExplorer.monkeyPatch": false still serves as a workaround in this case.

tipy01 commented 5 months ago

I got this issue too but it is linked to the my node.js version

node.js : v18.18.2 -> v20.13.1

the problem appears with v20 (maybe ts-node/esm acts differently depending on the node.js version)

I use ts-node 10.9.2

As previously noted "mochaExplorer.monkeyPatch": false may serve as workaround.