javascriptunit-testingtestingfunctional-testing

Javascript Unit test


I have a javascript app within 250 lines and want to add tests to that. Whenever i make a tiny change, i have to run tests for atleast 10 cases manually, which i want to automate.

I could have gone for frameworks as suggested in different posts, but the solution i want is minimum friction and codebase. Something like a single file for unit testing may work.

Is there a way for using JS testing without any frameworks ? I want to write Unit tests / functional tests both. Or if Frameworks is the only option, what frameworks are preferred in terms os ease of plugin to existing code + learning curve.


Solution

  • its really hard to setup automated unit tests with plain javascript without any framework. if you try to reinvent the wheel of existing javascript unit testing framework yourself, that might be huge effort than your 250 lines of code for which you are writing test.

    so if you are going for an framework, jasmine and qunitjs are promising unittesting framework for javascript.

    http://jasmine.github.io/

    https://qunitjs.com/