3

I'm somewhat informed with TDD and BDD with Ruby/Rails, but I will eventually need to use some form of testing with my JavaScript code. I use MooTools as a JS framework and I absolutely love how well I can organize and modularize my code with its codebase. But, sometimes, when I add new features to my application, I find that the functionality can easily break from how it worked before.

When it comes to testing JavaScrtpt code, does the testing itself fall short of user interaction? Is it really only to test the ins and outs of method and (emulated) classes in JavaScript? Or is there a UX testing practice where you can write unit tests to see if your application's UX behaviour is performing how it should be? I'm aware that "behaviour" is a broad term, but is there anyway that you can organize your JavaScript tests so that whenever you add something new then you can rest (somewhat) assured that your new code won't break anything from before? How is this done with any of the larger web apps out there?

1
  • Are you writing a thin client or a fat client? Commented Nov 15, 2011 at 14:45

1 Answer 1

4

It is perfectly fine, accepted and advised to use unit testing frameworks such as JSSpec or Jasmine (there are many others).

Then, you may do UI unit, functional and sometimes even integration testing with tools such as Ghostbuster or Selenium. These allow you to fake user events and interaction.

Ghostbuster is still quite young, so we don't know so much about “actual” uses, but Selenium is an industry standard (I know it is used at IBM, source: teacher working at IBM).

However, what you can't automatically test is UX. UX stands for User eXperience, and that's not something you test on software, only with real user testing.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for a very direct result. What I mean by "emulated" is essentially a class system that is created since the javascript language doesn't properly support regular OOP classes. So something like MooTools is required to make this work.
I understand what you mean (and meant), but I wouldn't say classes are “emulated” simply because they are not part of the base language. All OOP patterns can be implemented through prototype inheritance, and not “faked”. Anyway, that's out of the scope of the question. I'll edit my answer to remove this part.
BTW, since you didn't accept the answer, is there anything I missed / didn't get in your question? :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.