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

Issue: Requires reload of VS Code Window to pick up changed settings #16

Open
ManfredLange opened this issue Jan 10, 2025 · 0 comments
Open

Comments

@ManfredLange
Copy link

ManfredLange commented Jan 10, 2025

The Issue

I'm using a dev container, i.e. the VS Code extension for remote development.

Settings are stored in the usual .vscode/settings.json file.

When I change settings for this extensions, they are not picked up automatically as is the case for all other extensions I use. Instead I need to reload the VS Code window each time I make changes to the extensions settings.

This is quite surprising. I wasn't aware of it and spent considerable amount of time wondering whether I was changing the right settings. This waste of time is avoidable by doing what other extensions do, namely automatically reloading the configuration.

Also, it'd be nice if the extension would make it easier to set it up for pnpm and vitest, e.g. through better documentation or through a better set of settings.

For completeness I should mention that because we are using pnpm, we have removed "npm" from our dev containers. So it's essentially a node.js environment with "pnpm" instead of "npm". Therfore, I am of the opinion, that a configuration that shows "pnpm" as the package manager should not use "npm" for any of the other settings, e.g. preTest or postTest.

Extra: Sample Configuration for pnpm and vitest for Debugging and Running Tests

Note, this solution works only if you have a standard path to the directory containing your package.json file.

In my package.json file I added this script (other content left out for brevity):

{
   "scripts": {
      "vitest:run": "vitest --run --passWithNoTests"
   },
}

Then in .vscode/settings.json I have these settings for the extension (other content left out for brevity):

{
   "vscode-vitest.packageManager": "pnpm",
   "vscode-vitest.testCommand": "vitest:run",
   "vscode-vitest.executableOptions": {
      "run": true,
      "watch": false,
      "debug": true
   },
   "vscode-vitest.preTest": [
      "cd /work/service",
   ]
}

Note that the path in the preTest setting is specific to my environment. Since we are using dev containers we can standardize this across a large number of (all?) source code repositories, and it still works for all engineers despite of which directory they use for checking out the repository on their computer. It may be possible to set env variables and then use them as follows in settings.json:

{
  "some.setting": "${env:MY_VARIABLE}"
}

I did not explore this option, though, as our paths are standardized inside the dev containers.

To make the command "Debug (Vitest") work, this launch configuration works for us:

{
   "version": "0.2.0",
   "configurations": [
      {
         "type": "node",
         "request": "launch",
         "name": "Debug (Vitest)",
         "program": "${workspaceFolder}/node_modules/vitest/vitest.mjs",
         "args": [
            "run",
            "--testNamePattern",
            "${testPattern}"
         ],
         "cwd": "${workspaceFolder}",
         "runtimeExecutable": "pnpm",
         "runtimeArgs": [
            "exec",
            "node"
         ],
         "console": "integratedTerminal",
         "autoAttachChildProcesses": true,
         "skipFiles": [
            "<node_internals>/**"
         ],
         "env": {
            "NODE_OPTIONS": "--inspect"
         }
      }
   ]
}
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

1 participant