Scanning Javascript with Babel not working

  • Version of sonarqube: npm package “mocha-sonarqube-reporter”: “^1.0.1”,

  • Goal: Taking the following script written for typescript projects and translating it for javascript:
    test-sonar": "npx nyc mocha --require ts-node/register tests/**/*.spec.ts --reporter mocha-sonarqube-reporter --reporter-options output=./output/sonar/report.xml,

  • Attempted: using this script:
    test-sonar": "npx nyc ./node_modules/babel-cli/bin/babel-node.js src/**/**.spec.js && mocha --reporter mocha-sonarqube-reporter src/**/**.spec.js --reporter-options output=output/sonar/report.xml,

The issue is that when trying to run 'npm run test-sonar against our vanilla Javascript services, we are seeing valid javascript get rejected. for example “import _ from lodash”

import _ from ‘lodash’;
SyntaxError: Unexpected identifier