Open ankon opened 4 years ago
Do you have a sample repo to reproduce this?
Unfortunately the repositories I have with this issue are all private. I'll try to find some time on the weekend to produce a self-standing repository, maybe that will work.
Is it possible that you have another version of ts-node
installed somewhere else (and Mocha Explorer uses that one for some reason)?
Interesting question.
$ npm ls ts-node
project@9.6.0-0 /project
└── ts-node@8.10.2
$ node -p 'require.resolve("ts-node")'
/project/node_modules/ts-node/dist/index.js
Outside of any project
$ node -p 'require.resolve("ts-node")'
internal/modules/cjs/loader.js:969
throw err;
^
Error: Cannot find module 'ts-node'
...
Based on that: "no, I don't think there is another ts-node version involved". I don't install ts-node globally though, it is always part of the project dependencies. So I would assume the extension picks that up.... but I'm not sure that's an assumption that's safe to make.
In terms of configuration, in my .code-workspace
I have:
{
"folders": [ ... ],
"settings": {
"mochaExplorer.env": {
"TS_NODE_CACHE": "true",
"TS_NODE_FILES": "true",
"TS_NODE_COMPILER_OPTIONS": "{ \"module\": \"commonjs\", \"assumeChangesOnlyAffectDirectDependencies\": true }"
},
"mochaExplorer.monkeyPatch": false,
//"mochaExplorer.launcherScript": "node_modules/mocha-explorer-launcher-scripts/nyc",
"mochaExplorer.logpanel": true,
"mochaExplorer.pruneFiles": false,
"testExplorer.codeLens": true,
}
}
(The launcherScript is disabled because having that as a relative-to-the-project path is a bit ugly when using workspaces, I haven't tried whether I could point it potentially to the globally installed version).
I'm having the same issue with ts-node 8.10.2 and monkeyPatch false
The CodeLens on test is fine, but the describe is missing the lens.
Please add "mochaExplorer.logpanel": true
to your settings (if you haven't already) and open the "Mocha Explorer Log" output panel. It should contain a list of stacktraces starting with "[INFO] Worker: Looking for \<filepath> in Error:". Please post one of these messages (including both the filepath and the stacktrace) here, perhaps that could tell me what's going wrong.
I'm having the same issue with ts-node 8.10.2 and monkeyPatch false
Actually this issue was about a problem with monkeyPatch being true.
Please add "mochaExplorer.logpanel": true to your settings (if you haven't already) and open the "Mocha Explorer Log" output panel.
Added that, and tried to find a case where there is a problem. In fact, I actually tried to debug the extension, and by now I'm thinking that the problem might actually a user-issue. The lines you're mentioning of course only appear when monkeyPatching is enabled, so I was quite confused when they started appearing. And then I basically I added a breakpoint right at that place, and one-by-one opened my workspaces/projects with tests with that issue. Whenever the issue appeared the breakpoint didn't hit, and ultimately what happened here is that I had too many conflicting/confusing settings -- user settings, workspace settings, per-workspace project settings, some which had monkey patching enabled, and some had it disabled.
I now went through all of these settings, and removed the reference to the option from all places, and things are looking good!
So, just maybe: I'm an idiot, and there is no problem here. Sorry for that. I will report back when I see something odd appearing again.
@ankon i have a very basic setup. Nothing special here...
@hbenl here is the desired output
[2020-08-03 07:14:26.060] [INFO] Worker: Using the mocha package at /home/emil/code/watchdog-plotting/node_modules/mocha [2020-08-03 07:14:26.122] [INFO] Worker: Patching Mocha [2020-08-03 07:14:26.123] [INFO] Worker: Trying require('ts-node/register') [2020-08-03 07:14:26.375] [INFO] Worker: Trying require('source-map-support/register') [2020-08-03 07:14:26.390] [INFO] Worker: Loading files [2020-08-03 07:14:26.392] [INFO] Worker: Patching describe [2020-08-03 07:14:26.393] [INFO] Worker: Patching describe.skip [2020-08-03 07:14:26.393] [INFO] Worker: Patching describe.only [2020-08-03 07:14:26.393] [INFO] Worker: Patching it [2020-08-03 07:14:26.393] [INFO] Worker: Patching it.only [2020-08-03 07:14:26.393] [INFO] Worker: Patching it.skip [2020-08-03 07:14:26.393] [INFO] Worker: Copying it.retries [2020-08-03 07:14:26.393] [INFO] Worker: Patching context [2020-08-03 07:14:26.393] [INFO] Worker: Patching context.skip [2020-08-03 07:14:26.393] [INFO] Worker: Patching context.only [2020-08-03 07:14:26.393] [INFO] Worker: Patching specify [2020-08-03 07:14:26.393] [INFO] Worker: Patching specify.only [2020-08-03 07:14:26.393] [INFO] Worker: Patching specify.skip [2020-08-03 07:14:26.393] [INFO] Worker: Copying specify.retries [2020-08-03 07:14:26.394] [INFO] Worker: Patching describe [2020-08-03 07:14:26.394] [INFO] Worker: Patching describe.skip [2020-08-03 07:14:26.394] [INFO] Worker: Patching describe.only [2020-08-03 07:14:26.394] [INFO] Worker: Patching it [2020-08-03 07:14:26.394] [INFO] Worker: Patching it.only [2020-08-03 07:14:26.394] [INFO] Worker: Patching it.skip [2020-08-03 07:14:26.394] [INFO] Worker: Copying it.retries [2020-08-03 07:14:26.394] [INFO] Worker: Patching context [2020-08-03 07:14:26.394] [INFO] Worker: Patching context.skip [2020-08-03 07:14:26.394] [INFO] Worker: Patching context.only [2020-08-03 07:14:26.394] [INFO] Worker: Patching specify [2020-08-03 07:14:26.394] [INFO] Worker: Patching specify.only [2020-08-03 07:14:26.394] [INFO] Worker: Patching specify.skip [2020-08-03 07:14:26.394] [INFO] Worker: Copying specify.retries [2020-08-03 07:14:28.026] [INFO] Worker: Looking for /home/emil/code/watchdog-plotting in Error: at findCallLocation (/home/emil/.vscode-server/extensions/hbenl.vscode-mocha-test-adapter-2.7.2/out/worker/bundle.js:830:17) at /home/emil/.vscode-server/extensions/hbenl.vscode-mocha-test-adapter-2.7.2/out/worker/bundle.js:821:30 at Suite.<anonymous> (/home/emil/code/watchdog-plotting/src/watchdog-integration/test/metadata.integration.service.spec.ts:19:5) at Object.create (/home/emil/code/watchdog-plotting/node_modules/mocha/lib/interfaces/common.js:112:19) at context.describe.context.context (/home/emil/code/watchdog-plotting/node_modules/mocha/lib/interfaces/bdd.js:40:27) at /home/emil/.vscode-server/extensions/hbenl.vscode-mocha-test-adapter-2.7.2/out/worker/bundle.js:819:37 at Object.<anonymous> (/home/emil/code/watchdog-plotting/src/watchdog-integration/test/metadata.integration.service.spec.ts:7:1) at Module._compile (internal/modules/cjs/loader.js:1137:30) at Module.m._compile (/home/emil/code/watchdog-plotting/node_modules/ts-node/src/index.ts:858:23) at Module._extensions..js (internal/modules/cjs/loader.js:1157:10) [2020-08-03 07:14:28.026] [INFO] Worker: Looking for /home/emil/code/watchdog-plotting in Error: at findCallLocation (/home/emil/.vscode-server/extensions/hbenl.vscode-mocha-test-adapter-2.7.2/out/worker/bundle.js:830:17) at /home/emil/.vscode-server/extensions/hbenl.vscode-mocha-test-adapter-2.7.2/out/worker/bundle.js:821:30 at Suite.<anonymous> (/home/emil/code/watchdog-plotting/src/watchdog-integration/test/metadata.integration.service.spec.ts:28:5) at Object.create (/home/emil/code/watchdog-plotting/node_modules/mocha/lib/interfaces/common.js:112:19) at context.describe.context.context (/home/emil/code/watchdog-plotting/node_modules/mocha/lib/interfaces/bdd.js:40:27) at /home/emil/.vscode-server/extensions/hbenl.vscode-mocha-test-adapter-2.7.2/out/worker/bundle.js:819:37 at Object.<anonymous> (/home/emil/code/watchdog-plotting/src/watchdog-integration/test/metadata.integration.service.spec.ts:7:1) at Module._compile (internal/modules/cjs/loader.js:1137:30) at Module.m._compile (/home/emil/code/watchdog-plotting/node_modules/ts-node/src/index.ts:858:23) at Module._extensions..js (internal/modules/cjs/loader.js:1157:10) [2020-08-03 07:14:28.027] [INFO] Worker: Looking for /home/emil/code/watchdog-plotting in Error: at findCallLocation (/home/emil/.vscode-server/extensions/hbenl.vscode-mocha-test-adapter-2.7.2/out/worker/bundle.js:830:17) at /home/emil/.vscode-server/extensions/hbenl.vscode-mocha-test-adapter-2.7.2/out/worker/bundle.js:821:30 at Suite.<anonymous> (/home/emil/code/watchdog-plotting/src/watchdog-integration/test/metadata.integration.service.spec.ts:41:5) at Object.create (/home/emil/code/watchdog-plotting/node_modules/mocha/lib/interfaces/common.js:112:19) at context.describe.context.context (/home/emil/code/watchdog-plotting/node_modules/mocha/lib/interfaces/bdd.js:40:27) at /home/emil/.vscode-server/extensions/hbenl.vscode-mocha-test-adapter-2.7.2/out/worker/bundle.js:819:37 at Object.<anonymous> (/home/emil/code/watchdog-plotting/src/watchdog-integration/test/metadata.integration.service.spec.ts:7:1) at Module._compile (internal/modules/cjs/loader.js:1137:30) at Module.m._compile (/home/emil/code/watchdog-plotting/node_modules/ts-node/src/index.ts:858:23) at Module._extensions..js (internal/modules/cjs/loader.js:1157:10) [2020-08-03 07:14:28.029] [INFO] Worker: Looking for /home/emil/code/watchdog-plotting in Error: at findCallLocation (/home/emil/.vscode-server/extensions/hbenl.vscode-mocha-test-adapter-2.7.2/out/worker/bundle.js:830:17) at /home/emil/.vscode-server/extensions/hbenl.vscode-mocha-test-adapter-2.7.2/out/worker/bundle.js:821:30 at Object.<anonymous> (/home/emil/code/watchdog-plotting/src/watchdog-integration/test/metadata.integration.service.spec.ts:7:1) at Module._compile (internal/modules/cjs/loader.js:1137:30) at Module.m._compile (/home/emil/code/watchdog-plotting/node_modules/ts-node/src/index.ts:858:23) at Module._extensions..js (internal/modules/cjs/loader.js:1157:10) at Object.require.extensions.<computed> [as .ts] (/home/emil/code/watchdog-plotting/node_modules/ts-node/src/index.ts:861:12) at Module.load (internal/modules/cjs/loader.js:985:32) at Function.Module._load (internal/modules/cjs/loader.js:878:14) at Module.require (internal/modules/cjs/loader.js:1025:19)
It just keeps repeating this. Not sure if there is a problem with my code
I still have the issue #111 in my projects, even with ts-node 8.10.2 installed.
Disabling the monkey-patching in the settings fixes things.