You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As my project is based on ES6 modules, my tests start with import path from 'path'; instead of const path = require('path');
and
my package.json contains a property "type": "module".
When I start vscode with activated extension 'mocha-sidebar' I get the following errors showing that the extension can only handle commonjs modules:
trying to searching for tests using these settings:
mocha path: d:\Projekte\github\license-downloader\node_modules\mocha\index.js
test files location: test/**/*.spec.js
files to ignore: **/.git/**/*,**/node_modules/**/*
environmets: {}
requires: []
options: {}
if you find anything wrong please change those default settings
____________________________________________________________________________
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: d:\Projekte\github\license-downloader\test\license-report-file.spec.js
require() of ES modules is not supported.
require() of d:\Projekte\github\license-downloader\test\license-report-file.spec.js from d:\Projekte\github\license-downloader\node_modules\mocha\lib\mocha.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename license-report-file.spec.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from d:\Projekte\github\license-downloader\package.json.
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1080:13)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at d:\Projekte\github\license-downloader\node_modules\mocha\lib\mocha.js:436:36
at Array.forEach (<anonymous>)
at Mocha.loadFiles (d:\Projekte\github\license-downloader\node_modules\mocha\lib\mocha.js:433:14)
at c:\Users\Entwicklung\.vscode\extensions\maty.vscode-mocha-sidebar-0.22.2\lib\worker\findtests.js:86:15
at f (c:\Users\Entwicklung\.vscode\extensions\maty.vscode-mocha-sidebar-0.22.2\node_modules\once\once.js:25:25)
at Glob.<anonymous> (c:\Users\Entwicklung\.vscode\extensions\maty.vscode-mocha-sidebar-0.22.2\node_modules\glob\glob.js:151:7)
at Glob.emit (events.js:315:20)
at Glob._finish (c:\Users\Entwicklung\.vscode\extensions\maty.vscode-mocha-sidebar-0.22.2\node_modules\glob\glob.js:197:8)
at done (c:\Users\Entwicklung\.vscode\extensions\maty.vscode-mocha-sidebar-0.22.2\node_modules\glob\glob.js:182:14)
at Glob._processGlobStar2 (c:\Users\Entwicklung\.vscode\extensions\maty.vscode-mocha-sidebar-0.22.2\node_modules\glob\glob.js:637:12)
at c:\Users\Entwicklung\.vscode\extensions\maty.vscode-mocha-sidebar-0.22.2\node_modules\glob\glob.js:626:10
cant get tests [object Object]
Steps to Reproduce
see text above
Expected Results
no errors when using es6 module based tests
Actual Results
see above
Settings file
no special settings
Versions
VScode: v1.55.2
Mocha SideBar: v0.22.2
Node Version: v14.16.1
OS version
Linux
Mac
[ X] Windows
Example for reproducing
I can deliver one if needed
Result of my problem analysis
The problem comes from the fact that this extension uses mocha v5.2.0.
If using e.g. mocha v8.3.2, it could call mocha.loadFilesAsync()in findtests.js line 86 instead of the old mocha.loadFiles() , as the new 'async' version can handle commonjs and es6 modules
The text was updated successfully, but these errors were encountered:
Description
As my project is based on ES6 modules, my tests start with
import path from 'path';
instead ofconst path = require('path');
and
my package.json contains a property
"type": "module"
.When I start vscode with activated extension 'mocha-sidebar' I get the following errors showing that the extension can only handle commonjs modules:
Steps to Reproduce
see text above
Expected Results
no errors when using es6 module based tests
Actual Results
see above
Settings file
no special settings
Versions
OS version
Example for reproducing
I can deliver one if needed
Result of my problem analysis
The problem comes from the fact that this extension uses mocha v5.2.0.
If using e.g. mocha v8.3.2, it could call
mocha.loadFilesAsync()
infindtests.js line 86
instead of the oldmocha.loadFiles()
, as the new 'async' version can handle commonjs and es6 modulesThe text was updated successfully, but these errors were encountered: