I am currently deriving a javascript framework pattern as an architecture for the client side development for an upcoming large scale application that I will developing.
I am looking to go with a module observer pattern in which each control I develop will have its own javascript file, holding no knoweldge of the other controls.
From designing this framework for my application, I am looking to integrate in a testing mechanism for my modules - a unit testing mechanism for javascript. I am not aware of any such frameworks or how I may set up such. Any suggestions?
As part of such testing, I will also need to mock up http requests.
The library I will be using in development is jquery.
The JQuery team has QUnit.
As for abstracting out AJAX, you should wrap it appropriately or just test the data manipulation methods.
Jasmine may be what you are looking for. It has built-in mock up support, and does not rely on any other frameworks.
They also have a separate module for faking AJAX responses.
The setup is simple. Just download the standalone version, write some testing suites, and view the SpecRunner.html in a browser.
Consider using JsTestDriver to run your JS tests. The main benefit it provides - it can run your tests on continuous integration environment, which is essential for unit testing practice.
Some additional features:
List of mocking libraries you can find in another thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With