Closed ewrayjohnson closed 8 months ago
That error doesn't seem to have anything to do with this package. It's complaining about a file named .test.ts
, which I assume is in your project. I'm happy to help debug, but I'd need more information.
I poked around a bit and I think I have a solution for you. The extension needs to be configured to support ESM packages (package.json
that uses "type": "module"). This setting fixed the problem for me,
"mochaExplorer.nodeArgv": ["--loader", "ts-node/esm"]
This does remove the specific error, but just causes another error for me:
test/app.test.ts(2,5): error TS7022: '__importDefault' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
test/app.test.ts(2,67): error TS7006: Parameter 'mod' implicitly has an 'any' type.
test/app.test.ts(32,21): error TS2339: Property 'response' does not exist on type 'unknown'.
Thanks for your help.
Looks like it's trying to compile already complied typespcript. See, https://github.com/TypeStrong/ts-node/issues/883. My first guess would be to remove the "mochaExplorer.require": "ts-node/register"
setting if you have it, but in my testing, it worked the same with or without that setting. Here's my full mochaExplorer
settings. If you have anything other than those two things, try removing them.
"mochaExplorer.files": "test/**/*.ts",
"mochaExplorer.nodeArgv": ["--loader", "ts-node/esm"]
Here's the tsconfig.json
I used in case that helps.
{
"compilerOptions": {
"module": "Node16",
"target": "es2015",
"moduleResolution": "Node16",
"esModuleInterop": true,
"strict": true,
"allowJs": true
}
}
When I try to use this package with Mocha Test Explorer in VSCode I get this error: