airportyh/testem — pull request #118 by arobson (2012-12-11 03:52:29+00:00)
Title: Programmatic control of testem

This adds an api modules to testem and registers it as the main module so that a developer can require testem into their project and launch it that way. I've included a very brief set of snippets to show how the general calls work. It's pretty bare-bones, but it's currently everything we needed. Thanks so much for your help and thanks for testem!

```javascript
var Api = require('testem')
var api = new Api()
api.startDev( {
/*
progOptions:
file: test file
port: 7357
launch: list of launchers to use
skip: list of launchers to skip
test_page: the page to use to run tests
timeout: timeout for a browser
framework: test framework to use
src_files: list of files or file patterns
*/
} )

// to add a tab to testem, you can first create a logger and then add messages to it like so:
var logger = api.getLogger('title')
api.addTab(logger)
logger.addMessage( 'type', 'message text', 'blue' )

// you can clear the logger's tab by calling clear:
logger.clear()

// to restart the tests at anytime, you can call restart:
api.restart();
```