Terminus: control your browser from the command line

I’ve been saying for a while that I want to use Faye for automating JavaScript and integration testing, especially now that it has server-side clients. Well I took the first step in that direction this afternoon by hacking together Terminus, a distributed JavaScript console. You just install and run like so:

$ sudo gem install terminus
$ terminus
Terminus running at http://0.0.0.0:7004
Press CTRL-C to exit
>> 

Visiting the aforementioned http://0.0.0.0:7004 will give you a bookmarklet that you can drag up to your bookmarks bar. Running the bookmarklet while Terminus is running will connect the current page to your Terminus session, letting you run JavaScript on that page from the command line. And not just that page: every page you’ve connected will execute every line of script you type in. You may very well become drunk with power.

Anyway, have a play around and see if it’s useful. It’s still alpha quality and needs a fair few things adding, like per-page return values, connection reporting etc. It also needs some polish before you can drop the client script into your own apps and use it to drive tests. One step at a time.

If you’ve enjoyed this article, you might enjoy my recently published book JavaScript Testing Recipes. It’s full of simple techniques for writing modular, maintainable JavaScript apps in the browser and on the server.