Closed deerawan closed 8 years ago
hi - did you run npm install?
@chrisdias yes, I did. Did you get this error too?
@bpasero any ideas here? i can run tests under the debugger, but not from the command line.
We do not support to run tests from the command line at the moment. The only exception is https://code.visualstudio.com/docs/extensions/testing-extensions#_running-tests-automatically-on-travis-ci-build-machines
Tangentially related, I found this on a google search for the same issue.
My solution has been the following:
As I have been developing my extension, I abstract away all of the vscode module dependencies and wrap up my novel code in modules which don't rely on the vscode module. This makes my code testable in the large without adding a dependency on a third party module.
I don't know how complex any other extensions might end up being for people who find this, but I thought it might help kick off a new thought process for anyone who runs into a similar issue. Ultimately it's not useful to test whether the vscode module is working properly if you are developing an extension, so hopefully, your code is basically testable except where it touches the VS Code API.
Totally right way of writing tests :+1:
Tangentially related, I found this on a google search for the same issue.
My solution has been the following:
As I have been developing my extension, I abstract away all of the vscode module dependencies and wrap up my novel code in modules which don't rely on the vscode module. This makes my code testable in the large without adding a dependency on a third party module.
I don't know how complex any other extensions might end up being for people who find this, but I thought it might help kick off a new thought process for anyone who runs into a similar issue. Ultimately it's not useful to test whether the vscode module is working properly if you are developing an extension, so hopefully, your code is basically testable except where it touches the VS Code API.
I'm so miffed. I thought my tests were failing because I was using jest as my test runner. I was initially going to use this approach by defining types myself but I decided I should just set everything up with mocha. I spent all this time figuring out mocha only to find out that even with mocha you can't actually run the tests from the command line. I--
@prmichaelsen:
I definitely think you should consider breaking the dependency with a facade or something similar, defining a contract just for the facade, lift the interface definition out of the facade file, import it where you need the type, and do a cheap and dirty (or not so cheap and dirty) DI so you can text your module in isolation.
I run all of my extension tests from the command line. I simply fake the output from the vscode module and then test the behavior from there. This should all work from jest. Ultimately, the real vscode module requires a full running instance of vscode which can be massively frustrating.
Separately, if you want to test functionality in a live environment, you might be able to test electron applications with selenium. I haven't tried it myself, but I believe it is doable.
Hi,
I was trying to run the testing with command
mocha out/test
but got this error