Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to test javascript?

I'm building several jQuery plugin and going ahead I thought that will be useful to know some best practice for testing my code in order to be solid.

I usually use Selenium but this just for debugging.

I'd like to know the best way for doing some real test (like TDD, BDD, DDD) for my code.

Any suggestion will be appreciated.

like image 452
Andrea Turri Avatar asked Jan 05 '12 23:01

Andrea Turri


1 Answers

I use Jasmine https://github.com/pivotal/jasmine and would highly recommend it.

I don't think there is a "best" framework for test your code. I just know that you "should" test your code. So with that said, just find a test/spec framework your like and get testing!

I also at times use https://github.com/webadvanced/jMoney for testing small bits of code or for testing prototype code. It displays results in the console and does not require any setup or dependent files.

If you are more of a TDD guy, you can try QUnit http://docs.jquery.com/QUnit

like image 162
Paul Avatar answered Oct 12 '22 14:10

Paul