WebStorm 3.0 bundles it.
Users of other JetBrains IDE – PhpStorm, IntelliJ IDEA, PyCharm, RubyMine, and AppCode – can install it from the plugin repository following these instructions.
It allows you to enjoy all the benefits of JsTestDriver right from the comfort of your IDE. This includes the following features:
- starting and stopping the server;
- running and rerunning tests;
- filtering and viewing test results, navigation from results to source code;
- support for JsTestDriver configuration file: syntax and error highlighting, basic completion, navigation to referenced files;
- capturing messages sent to ;
- support for Jasmine, QUnit and JsTestDriver built-in assertion frameworks:
- quick-fixes for enabling global symbol reference resolving for each assertion framework (if you have QUnit or Jasmine tests in a project, you will be prompted to install the corresponding adapter);
- contextual code generation actions (Alt+Insert) for creating new tests, setup and teardown methods for each assertion framework;
- declarative HTML injection support for JsTestDriver built-in assertion framework.
The best way to understand how this works is to see it in action.
We have created a sample project for you. Please download greeter-sample.zip, extract it and open the project in your IDE.
If you open GreeterTest.js for the first time, you will see error highlighting on the TestCase method call expression. Position the caret on the error-highlighted code, press Alt+Enter/Option+Enter and choose “Add JsTestDriver assertion framework support” from the list of available intention actions.
Before you can run any of your tests you need to start the test server and capture at least one slave browser. The server does not have to reside on the machine where the test runner is, and the browsers themselves can be on different machines as well.
Starting JsTestDriver server locally
To launch the JsTestDriver server, look for the tool window at the bottom of the screen.
Click the green arrow to the right of the address bar to start the server. The status bar turns yellow to let you know the server is running, but has no slave browsers.
Then, copy the capture URL and paste it in a browser. The status bar turns green, and the corresponding browser icon lights up. Now you’re ready to run tests.
To run tests, right-click greeter.jstd and choose Run “greeter.jstd”. Tests will be run against the local JsTestDriver server.
In our case we have one failed test ‘GreeterTest.test greet null’. You can easily navigate from the stack trace to the source code that causes problems. You can also navigate from the test results tree to the test case/test function declaration using the F4 key.
In order to remove duplicated code that sets the greeter local variable, you can refactor the Greeter object creation to a special method called setUp, which is called before each test function is executed. Just invoke the Generate action by pressing Alt+Insert inside of a TestCase method call expression, and then choose “JsTestDriver Setup”.
Use the Shift+F10 keyboard shortcut to re-run the tests after changing code.
Test with pleasure!
Note: Users of PhpStorm, as well as other JetBrains IDE – IntelliJ IDEA, PyCharm, RubyMine, and AppCode – should install it from the plugin repository following these instructions.
Working with Windows Azure SQL Database in PhpStorm
PhpStorm provides us the possibility to connect to Windows Azure SQL Database right from within the IDE. In this post, we’ll explore several options that are available for working with Windows Azure SQL Database (or database systems like SQL Server, MySQL, PostgreSQL or Oracle, for that matter): …
Change signature refactoring in PhpStorm
A very powerful refactoring is the Change signature refactoring in PhpStorm. It enables us to modify a function signature in many ways: we can change the function name, change its visibility, add, remove and reorder parameters as well as rename parameters. (more…)…
Folding for imports in PhpStorm 6.0
In PhpStorm 6, we've introduced code folding for imports. Any list of imports will now be folded into a single line. This greatly reduced clutter in your editor when having a lot of imports! (more…)…
Drag & Drop Project Files to Remote Hosts in PhpStorm
The Remote Host pane allows us to work directly on a remote server through FTP, FTPS, SFTP or a local/network folder. A lot of people asked us to add drag & drop to the Remote Host pane in PhpStorm. Good news: PhpStorm 6 comes with drag & drop as well as copy & paste support from the pro…