2

I am new to Typescript, JavaScript and VScode Extensions

I have a vscode-test setup as outlined here:

https://code.visualstudio.com/api/working-with-extensions/testing-extension#custom-setup-with-vscodetest

Modeled after the helloworld-test-sample from here:

https://github.com/microsoft/vscode-extension-samples/tree/master/helloworld-test-sample

I want to download a vscode instance in the runTest.ts class main method and then install my extension on it. But by debugging I have found that the runTest.ts class is never called. The index.ts class is, the extension.test.ts class is, the tests run, but the runTest.ts class never is, which hinders me greatly, because I want to do what is shown in the first link.

This is also the case in the original example project, so I assume it is meant that way. But what is the purpose of the runTest.ts class then?

My goal is to actually install my extension in a test and see if it gets installed correctly and activated, but this fails because downloadAndUnzipVSCode fails when await is used and resolveCliPathFromVSCodeExecutablePath can only be used with a Promise<String>. So I am trying it like in the version shown in the first link.

Can someone maybe explain why the runTest.ts main method seems to be never called, and maybe how to implement a test that does download a VSCode instance, installs a local .vsix extension and evaluates if it was started correctly?

Thanks :)

2
  • I too am confounded by this! I was somehow able to get it to run once but can't reproduce it!
    – marvhen
    Oct 14, 2019 at 10:41
  • It depends on the way you run the tests which classes are called. Look below for how to do it if you want them to be called
    – Tobi
    Oct 15, 2019 at 11:10

1 Answer 1

2

Instead of launching a debug session from the vscode debug viewlet, you have to start the test task from the Terminal > Run Task menu item. In package.json these scripts are in the yeoman generated test extension and the last one runs runTest.js.

    "scripts": {
        "vscode:prepublish": "npm run compile",
        "compile": "tsc -p ./",
        "watch": "tsc -watch -p ./",
        "pretest": "npm run compile",
        "test": "node ./out/test/runTest.js"
    },

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.