HTML Scaffolding in Buster.js

Comments

I am a fan of buster.js, the JS testing framework influenced by JSTestDriver but taking things much further. It is however still a bit cutting edge. The resources section of Buster.js documentation, for example, is quite dense and cryptic. Here’s how to use a static HTML file as the basis of your tests.

Assume your project sits in wwwroot/, and your tests in tests/ next to it. Inside tests/ there is a folder with the HTML fixtures you want to use, tests/fixtures/index.html. Then in your config file, tests/buster.js, you simply add a resource pointing to it

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var config = module.exports;

config["My tests"] = {
    rootPath: "../",
    environment: "browser",
    libs: [
        "wwwroot/libs/**/*.js"
    ],
    sources: [
        "wwwroot/*.js"
    ],
    tests: [
        "tests/*-test.js"
    ],
    "resources": [{
        "path": "/",
        "file": "tests/fixtures/index.html",
        "headers": {
            "Content-Type": "text/html"
        }
    }]
}

Comments