ict.ken.be

Delivering solid user friendly software solutions since the dawn of time.

Wallaby

Categories: Testing

It's like NCrunch but for javascript.

http://wallabyjs.com/

JS Testing History

  • console
  • browser running tests
  • commandline with test watcher (needs stack copy)
  • resharper running tests (needs reference paths)
  • wallaby coverage and running tests

Wallaby

  • install through extensions
  • add wallaby.json to your solution

wallaby.json

{
  "files": [
    { "pattern" : "test/lib/chai.js", "instrument": false },
    "src/*.js"
    ],
    "tests": [
        "test/*Tests.js",
        "test/*Tests.ts",
        "test/*Tests.coffee"
    ],
    "testFramework": "mocha"
}
  • default test framework is jasmine
  • to exclude from coverage set instrument to false
  • right-click wallaby.json and select start
  • restart wallaby if you update the wallaby.json
  • yellow means partially covered (click to see what part was not processed)
  • screenshot of last runned test in context menu

Wallaby Visual Studio Shortcut Keys

  • Start Wallaby: alt-w alt-1
  • Stop Wallaby: alt-w alt-2
  • Restart Wallaby: alt-w alt-3
  • Run all tests: alt-w alt-4
  • Jump to failing test: alt-w alt-5
  • Context Menu: alt-shift-f10

Advanced

wallaby.js

var babel = require("babel");

module.exports = function (wallaby) {
    return {
        "files": [
            { "pattern": "test/lib/*.js", "instrument": false },
            "src/*.js"
        ],
        "tests": [
            "test/*Tests.js"
        ],
        "delays": {
            edit: 700,
            run: 300
        },
        "debug": true,
        "compilers": {
            "**/*.js": wallaby.compilers.babel  (
                {
                    babel: babel,
                    stage: 0
                }
            )
        },
        "env": {
            type: "node"
        }
    };
}

More