I’m following this vs code guide for writing extension tests and running into an issue. When trying to run the tests I get this error:
Error [ERR_REQUIRE_ESM]: require() of ES Module C:gitlangium-examplesouttestsuiteextension.test.js from c:gitlangium-examplesnode_modulesmochalibmocha.js not
supported.
Instead change the require of extension.test.js in c:gitlangium-examplesnode_modulesmochalibmocha.js to a dynamic import() which is available in all CommonJS modules.
Here is my tsconfig.json:
{
"compilerOptions": {
"target": "ES2017",
"module": "Node16",
"lib": ["ESNext"],
"sourceMap": true,
"outDir": "out",
"strict": true,
"noUnusedLocals": true,
"noImplicitReturns": true,
"noImplicitOverride": true,
"moduleResolution": "Node16",
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": [
"src/**/*.ts"
],
"exclude": [
"out",
"node_modules"
]
}
and my .vscode-test.js:
import { defineConfig } from '@vscode/test-cli';
export default defineConfig({
files: 'out/test/**/*.test.js',
mocha: {
ui: 'tdd',
timeout: 20000,
require: ['@babel/register', 'regenerator-runtime/runtime']
} });
I have looked at several things on the internet in regards to having Mocha work with ES modules, but haven’t been able to solve the problem yet.
Any help would be appreciated!