How can we execute Unit Tests against DOM manipulation?

后端 未结 3 1071
醉话见心
醉话见心 2021-02-13 06:43

The introduction to QUnit over at netTuts.com spawns an interesting exchange (never resolved) over how to apply unit tests against actions that manipulate the DOM. The following

3条回答
  •  清歌不尽
    2021-02-13 06:57

    The latest version of QUnit supports a #qunit-fixture element that lets you add HTML to the QUnit web page.

    E.g., in your HTML:

      test markup, will be hidden

      and in your JavaScript:

      $('').appendTo('#qunit-fixture');
      var result = add(a, b);
      
      equals(result, $('input#ResultTestBox').val(), "testing result box value");
      

    提交回复
    热议问题