I am surprised this has not been mentioned yet:
Simply open the .js file in question in VS Code, switch to the 'Debug Console' tab, hit the debug button in the left nav bar, and click the run icon (play button)!
Requires nodejs to be installed!
Answer from tenwest on Stack OverflowI am surprised this has not been mentioned yet:
Simply open the .js file in question in VS Code, switch to the 'Debug Console' tab, hit the debug button in the left nav bar, and click the run icon (play button)!
Requires nodejs to be installed!
This is the quickest way for you in my opinion;
- Open integrated terminal on visual studio code (
View > Integrated Terminal) - type
'node filename.js' - press enter
note: node setup required. (if you have a homebrew just type 'brew install node' on terminal)
note 2: homebrew and node highly recommended if you don't have already.
have a nice day.
Videos
After nine months there are now a couple answers to this question.
I created an open source project called Chutzpah - A JavaScript Test Runner. Chutzpah enables you to run JavaScript unit tests from the command line and from inside of Visual Studio. It also supports running in the TeamCity continuous integration server.
Another solution is part of the next version of Resharper. In Resharper 6 there is an integrated QUnit test runner.
It is possible to use JsTestDriver to be a test-runner in Visual Studio. Once a server has been started, with browsers attached, one can run tests directly from within Visual Studio.
The Console-window will then give the output of the test results. I won't go to implementation details here, but the following how-to should be enough to get you started on the actual setup of Visual Studio / JsTestRunner.
Console output from chrome and internet explorer (ignore my bad test-names):
JsTestDriver is mainly a test-running tool to verify multiple browsers. To get good unit-tests on the javascript itself, one can plug in other test-specific tools like JasmineBDD (jasmine to jstestdriver adapter).
JsTestDriver also opens up for the possibility to test against multiple browsers as a build step on your continuous integration server ie: Hudson (Continuous Integration with Hudson and jstestdriver). This then allows a dev to test against a certain browser or two while developing locally, but then verify the result against any range of OS / browser combinations on the build server.