An idea of how to make JavaScript testable, presented at Stir Trek 2011. The world of JavaScript frameworks has changed greatly since then, but I still agree with the concepts.
into jQuery", function() { it("should work, but it's kind of a pain", function() { element = $('<div>text</div>'); element.text("some more text"); expect(element.text()).toEqual("some more text"); }); });
new jQueryView("Client", element); registerObjectProperties(this, view, ['Username']); } The Client class now has the following methods: getUsername setUsername showUsername hideUsername clickUsername pressKeyInUsername keyDownInUsername enableUsername disableUsername whenUsernameChanges whenUsernameClicked whenUsernameIsClicked whenUsernameGainsFocus whenUsernameLosesFocus whenKeyIsPressedInUsername whenKeyDownInUsername
new jQueryView("Client", element); registerObjectProperties(this, view, ['SendButton']); } The Client class now has the following methods: showSendButton hideSendButton clickSendButton enableSendButton disableSendButton whenSendButtonClicked whenSendButtonIsClicked
new jQueryView("Client", element); registerList(this, view, ['Tweets']); } The Client class now has the following methods: appendToTweets prependToTweets getTweets