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

Support running extension tests through cmd line #118

Closed
jpoon opened this issue Nov 18, 2015 · 18 comments
Closed

Support running extension tests through cmd line #118

jpoon opened this issue Nov 18, 2015 · 18 comments
Labels
feature-request Request for new features or functionality

Comments

@jpoon
Copy link

jpoon commented Nov 18, 2015

Add support for running plugin/extension tests through the command line. This is particularly useful for things like CI. I was able to setup gulp+mocha, but any tests that reference vscode doesn't work.

Paraphrasing @bpasero, "this is a consequence of having an extension host that runs your plugin. This host is really the entire VS Code app and cannot be emulated from the command line easily. "

@Tyriar
Copy link
Member

Tyriar commented Nov 18, 2015

+1 - I believe atom manage to do this using a similar mechanism to Chromium's browser tests.

@bpasero
Copy link
Member

bpasero commented Nov 19, 2015

+1 this is on our backlog. however you will not be able to run tests without having a windowing system because in order to provide the VS Code APIs for the tests we still need to open a window.

@bpasero
Copy link
Member

bpasero commented Nov 24, 2015

This will be supported in the next release with the following syntax: code --extensionDevelopmentPath=<path to extension> --extensionTestsPath=<path to compiled tests>

The output goes directly to console and the exit code is set properly.

Note: in order for the exit code to function properly you will need vscode@0.10.6 at least as dependency from your extension.

@bpasero bpasero closed this as completed Nov 24, 2015
@bpasero
Copy link
Member

bpasero commented Nov 24, 2015

@jpoon @Tyriar maybe I closed this too early. What you can now do is run tests from the command line but only if code is not already running. This should however be good enough for running extension tests as part of Travis CI. We are actually able to run some of our API tests on Mac and Linux through Travis even though the tests require a real code instance to spawn.

@Tyriar
Copy link
Member

Tyriar commented Nov 24, 2015

@bpasero will that constraint go away when launchNewInstance (or whatever it will be) is set to true? #48

@bpasero
Copy link
Member

bpasero commented Nov 24, 2015

@Tyriar unfortunately not.

@jpoon
Copy link
Author

jpoon commented Nov 26, 2015

@bpasero What release should have this? 0.10.2?

@bpasero
Copy link
Member

bpasero commented Nov 26, 2015

@jpoon no, mid december!

@jpoon
Copy link
Author

jpoon commented Dec 29, 2015

Thanks @bpasero.

It looks like tests that rely on the active window fail (vscode.window.activeTextEditor => undefined). I'm not sure if this is inherent to Travis -- does it allow you to open a window?

Unfortunately, I'm running on Windows and can't debug this further (any plans for adding Windows support?). On Travis, I do see these warnings:

Xlib: extension "RANDR" missing on display ":99.0".

@bpasero
Copy link
Member

bpasero commented Dec 30, 2015

Yes we have tests that rely on that too, if you have the tests somewhere online I can try to run them on Mac/Linux from the command line to see whats going on.

@jpoon
Copy link
Author

jpoon commented Dec 30, 2015

Are your tests that rely on vscode.windowactiveTextEditor` working?

Guess I'm doing something wrong on my end then. Our tests are here: https://github.com/VSCodeVim/Vim/tree/master/test

@bpasero
Copy link
Member

bpasero commented Dec 30, 2015

@jpoon check out our tests that we manage to get run: https://github.com/Microsoft/vscode/tree/master/extensions/vscode-api-tests

@bpasero
Copy link
Member

bpasero commented Dec 30, 2015

And are those tests working when you run them via Code?

@jpoon
Copy link
Author

jpoon commented Jan 2, 2016

Yep. Tests work when running with Code. Here's one of the failed builds: https://travis-ci.org/VSCodeVim/Vim/builds/99793291

  1) Mode Handler ctor:
     TypeError: Cannot read property 'selection' of undefined
      at new Motion (src/motion/motion.ts:22:61)
      at new ModeHandler (src/mode/modeHandler.ts:19:24)
      at Context.<anonymous> (test/mode/modeHandler.test.ts:8:27)

where line 22 of motion.ts is:

    public constructor(mode : MotionMode = null) {
        let currentPosition = vscode.window.activeTextEditor.selection.active;

@bpasero
Copy link
Member

bpasero commented Jan 2, 2016

@jpoon in that test I am not seeing code that would open a text editor, so I wonder how the tests run green when running inside Code, maybe you can explain: https://github.com/VSCodeVim/Vim/blob/master/test/motion.test.ts

Does it make any difference if you run the tests locally using the same command you run in travis?

@jpoon
Copy link
Author

jpoon commented Jan 2, 2016

I am not seeing code that would open a text editor

💡 -- that was it! When running in Code, it seems as though the tests automatically open a text editor, hence didn't need to do it explicitly. After refactoring my tests to open an editor....

https://travis-ci.org/VSCodeVim/Vim/builds/99801078 🎉

Thanks @bpasero .

@bpasero
Copy link
Member

bpasero commented Jan 3, 2016

@jpoon very cool!

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants
@jpoon @bpasero @Tyriar and others