Can you use breakpoints in extension tests? - visual-studio-code

When writing integration tests for a VSCode extension, are you able to use breakpoints?
I am running the tests in the default hello-world example from the yeoman generator. My breakpoints are not being hit. I had a guess and set stopOnEntry to true in launch.json, however it didn't help.
Thanks

Yes, this should work, if not I suggest you file an issue over at https://github.com/Microsoft/vscode

Related

Visual Studio Code does not see changes in F# Solution

Currently I am trying to use Visual Studio Code with Ionide to build a F# Solution. To describe my problem, i first describe what i have done, and what works.
I created a solution with two Projects. One Project is a Queue that contains a F# library. Another project is Queue.Test that is a console application that uses the Queue library, and should contain the Tests for the Queue library.
I'm using .Net6 and created the solution and Project with the dotnet cli tool.
In general, i can build the project with dotnet and i also can use everything in Visual Studio Code. I load the Folder that contains both projects, and Visual Studio Code loads the library.
I am able to edit the Library and my Console application. In my Console application i also can access the Queue and so on. Autocompletion works, and so on.
But, there is one problem. When i add a new function to my library, let's say Queue.help then in my Console application, i cannot see that function. It doesn't show in autocomplete, and when I write code that uses that function i get a compiler error telling me that function doesn't exists.
I can Build/Rebuild from VS Code or from CLI but the problem goes not away.
The only way Ionide starts to see the new function is by building the library AND restarting VS Code. As long i don't restart, it seems to not update the generated dll (i guess).
This is sure annoying, as i don't want to reload/restart VSCode everytime I add a new function to my library.
So my question: How i can I fix this?
What i want is to be able to change my library, and at the same time write tests in the other project and get full Code autocompletion.
Does somebody else have the same problem, or should I change my workflow?
What can i do, to debug this problem on my own?
Some tips?
This issue is fixed by the recent version of Ionide 5.10.1

vscode.executeDefinitionProvider returns empty vscode.Location[] when tests are called via package manager

I'm creating my first VS Code extension, but now I stuck while testing my extension automatically.
If I run my automated tests out of VS Code everything works fine, but I want to run the tests also in a continuous integration pipeline which is why the tests should also run if I call them with npm run test.
With npm run test most of my tests run successful, but as far as a test-method depends on the "vscode.executeDefinitionProvider"-output the tests fail, because it does not find any definitions.
await vscode.commands.executeCommand<vscode.Location[]>('vscode.executeDefinitionProvider', document.uri, positionToSearchForSymbols)
.then(definitions => {
if(definitions.length > 0){
//this one is called if I run the tests out of Visual Studio Code
} else{
//this one is called if I run the tests via npm rum test
}
});
Do you have any idea what I'm doing wrong? Why does npm run test behave different than running the tests out of VS Code?
Thanks in advance for your help.
David
Well, I got informed that VS Code sends a message to the language provider (in my case the al language extension) and that the issue has to be on the site of the language provider. Because the issue is not related to VS Code, I will close this question.
You need to setup your test environment to use specific extensions: How do I run integration tests for a vscode extension that depends on other extensions
You need to make sure that the extensions (in your case: DefinitionProvider) are activated before your tests start:
VSCode extension testing: Use `vscode.executeDefinitionProvider` in test
You might run into a situation where nothing of the above works for you. In that case this might help:
https://stackoverflow.com/a/69400358/6702598

VSCode metals, run specific ten in scalatest

is there a way in vscode with metals scala plugin, run specific test scenario ?
Like in IntelliJ ?
If you mean specific test clause in say a scalatest class, I'm pretty sure the answer is "no".
Workaround could be to add a launch configuration and pass args to just run the test you want with -z: https://scalameta.org/metals/docs/editors/vscode.html#via-a-launchjson-configuration
Or just ignore-tag the others.

I want to use the Babel plug-in: optional-chaining, but the vscode console prompted me incorrectly. How can I solve this problem?

I created a new project with the create-react-app scaffold, and then I wanted to use the optional-chaining plug-in of babel. I installed the package according to the document and configured it, but vscode prompted grammatical errors. What can help me? please.
this is my package.json.
this is the problem:
If you are using CRA there is probably no way instead of ejecting project and applying Babel presets manually (according to https://github.com/facebook/create-react-app/issues/4604).
However, if you are decided to use eject there should be able to add plugin to babel config which is described here https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining. Probably applying stage-0 preset of Babel (https://babeljs.io/docs/en/babel-preset-stage-0) can also be a solution.
Edit: see also Null-safe property access (and conditional assignment) in ES6/2015
The error you are seeing is from Visual Studio Code's built-in JavaScript and/or TypeScript validator. In order to circumvent this, add this to your vscode settings.json file:
"javascript.validate.enable": false
Additionally you can disable the built-in TypeScript validator like this:
"typescript.validate.enable": false
Once those are disabled, eslint will take over and show you the proper errors when applicable.

Running doctests from Pydev?

Is there any straightforward way or should I use an external tool like Nose?
Pydev 1.6.4 provides support for a nose test runner.
http://pydev.org/manual_adv_pyunit.html describes how to configure the nose test runner.
To run doc tests, you'll need to specify the --with-doctest switch for the nose runner.
Xv's answer is correct, unless you have tests that are in external files (like testable specifications) in which case you should add the doctest-extension=txt switch (substituting txt for whatever your extension is).