mocha-sidebar icon indicating copy to clipboard operation
mocha-sidebar copied to clipboard

Command 'mocha-maty.refreshExplorer' not found (again)

Open sagimann opened this issue 5 years ago • 4 comments

Description

'command 'mocha-maty.refreshExplorer' not found' pops up when trying to refresh the test sidebar I've read previous issues on the error message, which was supposed to be fixed in v0.20.x, however, I'm using a newer version

Thanks!

Steps to Reproduce

  1. create a project with src/ and test/ sibling folders
  2. under src, run npm init, npm install
  3. Go to the test sidebar, wait for the test progress bar to stop
  4. Click 'refersh' icon

Expected Results

No error is shown and the tests appear

Actual Results

The refresh process should show the tests instead of the error message

Settings file

none

Versions

  • VScode: v1.41.1
  • Mocha SideBar: v0.22.2
  • Node Version: v10.16.0

OS version

  • [ ] Linux
  • [ x ] Mac 10.15
  • [ ] Windows

sagimann avatar Jan 12 '20 07:01 sagimann

Update: it seems that this settings.json works around the issue:

{
    "mocha.files.glob": "test/**/*.js",
    "mocha.nycPath": "/Users/xxx/test/mocha1/src/node_modules/nyc",
    "mocha.env": {
        "NODE_PATH": "/Users/xxx/test/mocha1/src/node_modules"
    }
}

After I put this file under /.vscode/settings.json, the Mocha Sidebar can detect the tests. But this is not a completely viable workaround because it only seems to work with fully qualified paths for nycPath and NODE_PATH. If I either try to use a relative path or ${workspaceFolder}, it breaks as before: src/xxxx ${workspaceFolder}/src/xxxxx

sagimann avatar Jan 12 '20 08:01 sagimann

I'm not familiar with VSCode extension development, but after checking your lib/config.js and sending a few debug messages to VSCode, it seems that mocha.xxx settings in settings.json do not support VSCode env variables. I was easily able to add such support for specific variables by changing lib/config.js as follows:

const substituteVSCodeVars = (value) => {
  return value.replace('${workspaceFolder}', vscode.workspace.rootPath);
}

    if (nycPath) {
      return substituteVSCodeVars(nycPath);
    }
...
let tmpEnv = [];
try {
    tmpEnv = JSON.parse(JSON.stringify(getConfiguration().env));
    for (let k in tmpEnv) tmpEnv[k] = substituteVSCodeVars(tmpEnv[k]);
} catch (error) {
    messages.sendPopUpMessage(error.stack);
}
const env = () => tmpEnv;

sagimann avatar Jan 12 '20 10:01 sagimann

I got this BUG!

kenkinky avatar Mar 18 '20 07:03 kenkinky

I am also experiencing this bug though I cannot execute any of the mocha sidebar commands. I have tried to uninstall and reinstall the extension and my VSCode instance as well as use full paths. No luck on my end. I didn't have any special options added on.

brittaniSavery avatar Apr 16 '20 03:04 brittaniSavery