Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks
sagimann opened this issue Jan 12, 2020 · 4 comments
Open
2 tasks

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

sagimann opened this issue Jan 12, 2020 · 4 comments

Comments

@sagimann
Copy link

sagimann commented Jan 12, 2020

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
Copy link
Author

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
Copy link
Author

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;

@kenkinky
Copy link

I got this BUG!

@brittaniSavery
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants