Closed kakins closed 4 years ago
Is tape-catch
actually in your dependencies or is it perhaps installed globally on the other machines? Do you use a lockfile (i.e. package-lock.json
)? That is necessary to ensure that npm install
will have the exact same result on all machines.
Getting a very similar error on a fresh npm install and a barebones project:
Error: Cannot find module 'tape'
Require stack:
- /home/snepsts/mocha-test-explorer-test/node_modules/isarray/test.js
- /home/snepsts/mocha-test-explorer-test/node_modules/mocha/lib/esm-utils.js
- /home/snepsts/mocha-test-explorer-test/node_modules/mocha/lib/mocha.js
- /home/snepsts/mocha-test-explorer-test/node_modules/mocha/index.js
- /home/snepsts/.vscode/extensions/hbenl.vscode-mocha-test-adapter-2.5.0/out/worker/bundle.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/snepsts/mocha-test-explorer-test/node_modules/isarray/test.js:2:12)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/snepsts/mocha-test-explorer-test/node_modules/isarray/test.js',
'/home/snepsts/mocha-test-explorer-test/node_modules/mocha/lib/esm-utils.js',
'/home/snepsts/mocha-test-explorer-test/node_modules/mocha/lib/mocha.js',
'/home/snepsts/mocha-test-explorer-test/node_modules/mocha/index.js',
'/home/snepsts/.vscode/extensions/hbenl.vscode-mocha-test-adapter-2.5.0/out/worker/bundle.js'
]
}
Any clue what this could be?
EDIT: This message is from the output
part of the terminal, after clicking the Error while loading tests - click to show
button in the test explorer.
After rereading I noticed kakins mentioned he doesn't know if he has updated this plugin but other machines may not have.
I do not get this error on version 2.3.0
, but 2.4.0
and 2.5.0
do have this error. Hopefully that is useful information!
Alright, final update from me:
I looked through commits between 2.3.0 and 2.4.0 and noticed this commit: https://github.com/hbenl/vscode-mocha-test-adapter/commit/15c19b54f3d2aa18a62c4604cba85e336c99a568
This commit is why these errors are showing up (at least for me). Let me explain:
My team uses ${servicename}-test.js
to house the tests for our ${servicename}.js
files. If you have a very open-ended glob like so to match it: **/*test.js
... then it will run any file with the name test.js
, including ones in node_modules
. Thus causing these failures. We use this glob bc we want to catch all of our tests ending with test.js
, but I suppose it is too liberal.
Hopefully that helps you @kakins
@Snepsts Thank you, I will certainly take a look! And I will confirm whether that solves the issue for me.
@Snepsts It looks like I have the same glob **/*test.js
. What ended up being your solution for fixing this while still grabbing all the tests in your project?
Actually I ended up doing this:
"mochaExplorer.files": "**[!node_modules]/*test.js",
My solution was to do {app,src}/**/*test.{js,ts}
since that is how our structures are, but I think I like yours more! Thanks for sharing it!
Actually your solution worked better. Mine didn't seem to grab all of the folders I needed. Specifying folders got it working.
Has anyone ever run into this error? I have run npm install. Our test project works on other machines but not mine, not sure if perhaps I've updated the test runner and they haven't.
I get this error when refreshing the tests in Test Explorer. Tests do not appear in explorer.