How can we execute Unit Tests against DOM manipulation?

后端 未结 3 1190
醉话见心
醉话见心 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:56

    Surely what you actually care about is that the val method gets called on the return value of $(“input#ResultTestBox”)—you don't need to test the functionality of the jQuery method itself. Why not inject a mock implementation of the jQuery object and test against that?

提交回复
热议问题