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

How to test extensions providing code actions? #98

Closed
miffels opened this issue May 11, 2021 · 4 comments
Closed

How to test extensions providing code actions? #98

miffels opened this issue May 11, 2021 · 4 comments

Comments

@miffels
Copy link

miffels commented May 11, 2021

Hey,

I am building an extension providing code actions and I am unclear on how to use the API to validate that the plugin loads correctly, that code action providers are registered, that errors are properly reported, quick fixes can be correctly applied, decorators are added etc. It appears to me that this is a documentation/tutorial issue as well: I was shocked to see that none of the extensions I am using implements any such tests in their source code (well, I stopped looking after checking like 10). It would appear I am not the only one having trouble figuring this out, otherwise I cannot explain why people limit themselves to checking if their config loads fine. Is there anything you could share to help me get started? I have a gut feeling that this would involve the extension context, but I am not really sure. The samples in this repo provide very limited value since they appear to be limited to "hello-world-y" Array.indexOf tests. It would be very helpful to have a few more showcases using VSCode APIs.

Cheers,
Michael

@apupier
Copy link
Contributor

apupier commented Jul 12, 2021

Agree that an official documentation would be awesome.

If it can help:
For completion part, you can find one way to do it here https://github.com/camel-tooling/camel-lsp-client-vscode/blob/master/src/test/completion.util.ts which tried to stay low level.
And another way using UI tests: https://github.com/camel-tooling/camel-lsp-client-vscode/blob/master/src/ui-test/xml_completion_support_test.ts

@miffels
Copy link
Author

miffels commented Jul 29, 2021

Thanks @apupier! That helps a lot.

@dario-piotrowicz
Copy link

@miffels I've stumbled across this issue as I was experiencing the same.

I checked various popular extensions and I was shocked to see the lack of tests, and the abundance of the initial yeoman ones:

   test('Sample test', () => {
    assert.strictEqual(-1, [1, 2, 3].indexOf(5));
    assert.strictEqual(-1, [1, 2, 3].indexOf(0));
  });

🤯

I've been writing a simple vscode extension and decided for simplicity and speed to just extract login into functions and test those function with jest, which does seem to be working pretty well.

Anyways that obviously can take you only so far...

In my extension I've added code actions and it would be great to be able to have integration tests which could check if those are properly being shown and at their execution if they update the document in the correct way...

So, I just wanted to ask you, have you had any luck with the code action tests?

@connor4312
Copy link
Member

Merging into microsoft/vscode#94746

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

4 participants