Skip to content
airportyh edited this page Jul 20, 2012 · 2 revisions

Testem is getting some use from a small number of enthusiastic users. They are giving good feedback. One area that needs to be improved is extensibility. There are tons of different options out there when it comes to web development so everyone's needs might be different. Some of the common requests so far are

  • code preprocessors(LESS, Sass, Coffeescript, Browserify, etc)
  • running tests in Node
  • running tests in the cloud via BrowserStack
  • proxy server to interact with existing http server for integration testing (to get around cross domain restriction), so you can access ajax and other resources directly from a rails app, php app, node app, or whatever

High Level Approach

Because there are so many different kinds of needs, it is unscalable in the long run to try to support everything that's out there. So we should have a very simple plugin architecture. I think a large class of functionality can be supported by allowing them to call out to the shell to run a command at different points, so a large part of extension will be based simply on user specified system commands.

Configurable Launchers

Here's what the syntax might look like to configure your own launcher (using the json syntax - yaml would also work)

{
    "launchers": {
        "Mocha": {
            "command": "mocha my_tests.js",
            "tap_output": true
        }
    }
}

"tap_output" is an option that tells Testem to parse the stdout of the program as TAP. If not present, it will just assume the program will talk to Testem using socket.io just as the browser would.

This would be able to also support BrowserStack as long as there's an executable you can call that will spin up a browser in the cloud and point to a URL

browserstack-launch http://myurl.com/ -browser IE7

The other problem with browserstack is the need for proxying, but you can start the proxying process with a command, so add that in and you have

show 3000; browserstack-launch http://you.showoff.io/ -browser IE7

Although, having to add a command listing for each different browser type in the config will make a very long file. So we should probably add a browserstack specific setting.

{
    "launchers": {
        "BrowserStack": {
            "url": "http://you.showoff.io/",
            "browsers": [
                "IE7",
                "Firefox 17",
                ...
            ]
        }
    }
}

Something like that, maybe. Although at this point we have started to add BrowserStack functionality directly into Testem.

Configurable Preprocessors

Pre-processors like LESS, Sass, Coffeescript, Browserify are simply scripts that have to be run before the tests are restarted. We should add a new property in the config like

{
    "preprocess": "coffeescript *.coffee; less *.less; browserify main.js"
}

I believe this will accomodate all those cases.

Proxy Server

For integration testing with an existing http server/app, we could embed a proxy server into Testem itself.

{
    "proxy": {
        "/ajax_calls": "http://myapp.local/",
        "*": "http://fallback.local"
    }
}

Inside the "proxy" property, you can declare a mapping between path components to URLs. "*" is a fallback, meaning a request to anything that is not found otherwise, would fallback to using proxying.