hbenl / vscode-mocha-test-adapter

Mocha Test Adapter for the VS Code Test Explorer
MIT License
91 stars 31 forks source link

@babel/register is not working #119

Closed bbellovic closed 4 years ago

bbellovic commented 4 years ago

I am trying to use mocha + docker container, however, it seems like @babel/register is not working original command:

BABEL_DISABLE_CACHE=1 mocha --require @babel/register --reporter spec --timeout 90000 --full-trace 'app/api/sql/graphql/schema.internal.tests/*.test.js' 'app/api/sql/models/classes/*.test.js'

I have following vscode settings.json:

    "mochaExplorer.launcherScript": "docker-launcher.js",
    "mochaExplorer.mochaPath": "node_modules/mocha",
    "mochaExplorer.debuggerConfig": "Debug in Docker",
    "mochaExplorer.require": "@babel/register",
    "mochaExplorer.nodePath": "node",
    "mochaExplorer.env": {
       "BABEL_DISABLE_CACHE": "1"
    },
    "mochaExplorer.logpanel": true,
    "mochaExplorer.files": "app/api/sql/**/*.test.js",
    "mochaExplorer.optsFile": "mocha.opts",

and following mocha.opts:

--require @babel/register
--reporter spec
--timeout 90000 
--full-trace

but when I try to load tests in ui I keep receiving following error:

import chai from 'chai';
^^^^^^
SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1117:16)
    at Module._compile (internal/modules/cjs/loader.js:1165:27)
    at Module._compile (/home/node/workspace/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
    at Object.newLoader [as .js] (/home/node/workspace/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:1050:32)
    at Function.Module._load (internal/modules/cjs/loader.js:938:14)
    at Module.require (internal/modules/cjs/loader.js:1090:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at /home/node/workspace/node_modules/mocha/lib/mocha.js:384:36

This error indicates that @babel/register was not used

IanTeda commented 4 years ago

Hey @bBellovic, did you resolve this one. Having the same issue requiring @babel/register?