Upgrade to Pro — share decks privately, control downloads, hide ads and more …

"Buster.JS" ClinetSide Javascript testing

KAZUMA Ukyo
October 15, 2012

"Buster.JS" ClinetSide Javascript testing

a Buster.JS introduction

KAZUMA Ukyo

October 15, 2012
Tweet

More Decks by KAZUMA Ukyo

Other Decks in Programming

Transcript

  1. ClientSide JavaScript Testing
    Buster.JS

    View Slide

  2. KAZUMA UKYO
    @yaakaito
    yaakaito.org
    github.com/yaakaito

    View Slide

  3. KAZUMA UKYO
    @yaakaito
    yaakaito.org
    github.com/yaakaito

    View Slide

  4. View Slide

  5. a ?P?

    View Slide

  6. View Slide

  7. View Slide

  8. View Slide



  9. A browser JavaScript testing toolkit.
    It does browser testing with browser automation
    (think JsTestDriver), QUnit style static HTML page
    testing, testing in headless browsers (PhantomJS,
    jsdom), and more. Take a look at the overview!

    View Slide



  10. A browser JavaScript testing toolkit.
    It does browser testing with browser automation
    (think JsTestDriver), QUnit style static HTML page
    testing, testing in headless browsers (PhantomJS,
    jsdom), and more. Take a look at the overview!

    View Slide

  11. View Slide



  12. A browser JavaScript testing toolkit.
    It does browser testing with browser automation
    (think JsTestDriver), QUnit style static HTML page
    testing, testing in headless browsers (PhantomJS,
    jsdom), and more. Take a look at the overview!

    View Slide

  13. View Slide

  14. View Slide

  15. View Slide

  16. View Slide

  17. Setup

    View Slide

  18. $ npm install -g buster

    View Slide

  19. Tests

    View Slide

  20. buster.js
    var runner = module.exports;
    runner["browser test"] = {
    env : "browser",
    sources : [
    "lib/test_object.js"
    ],
    tests : [
    "tests/test_object_tests.js"
    ]
    }

    View Slide

  21. test_object.js
    var test_object = {
    number : 10,
    dom : function(target) {
    target.innerHTML = "Hello Buster.JS!"
    }
    }

    View Slide

  22. test_object_tests.js
    buster.testCase("number", {
    "test example" : function() {
    assert.same(10, test_object.number);
    }
    });

    View Slide

  23. Run

    View Slide

  24. $ buster server
    buster-server running on
    http://localhost:1111
    $ open http://localhost:1111

    View Slide

  25. View Slide

  26. View Slide

  27. View Slide

  28. $ buster test
    Chrome 22.0.1229.94, OS X 10.7 (Lion): .
    Firefox 14.0.1, OS X 10.7 (Lion): .
    Mobile Safari 6.0, OS X (iPhone): .
    3 test cases, 3 tests, 3 assertions, 0
    failures, 0 errors, 0 timeouts
    Finished in 0.015s

    View Slide

  29. BDD style

    View Slide

  30. test_object_spec.js
    buster.spec.expose();
    describe("A test_object module", function () {
    it("dom", function () {
    var p = document.createElement("p")
    test_object.dom(p);
    expect(p.innerHTML).toEqual("Buster.JS");
    });
    });

    View Slide

  31. Bundles

    View Slide

  32. sinon.js
    when.js
    mock library
    async testcase

    View Slide

  33. Thanks!

    View Slide