Below is a simple function to generate object with query string of given url,
And a simple test case for it,
You can run this test with Mocha with below command,
Karma is a test runner which runs the test cases in real browsers and across devices. Sounds awesome doesn’t it? Setting it up is also straight forward which is very well explained in their main website.
After installing & configuring, you can install the browser launchers you need and update the config file.
Now run the command to start karma, It will open the configured browsers and execute the test cases in all.
The cool part about Karma is that, you could start it and add any device to it and the test cases gets autmatically executed for that device. You can see below, I added my Android phone to the running test just by opening the url in my mobile browser.
Set autoWatch: true in karma.config.js file to allow test cases execution whenever the files change. Also, you could debug the code by adding a line debugger to four function & open Developer tools in your browser to start debugger. Exciting right? Go ahead & try for yourself.
Have setup boilerplate in Git repo with some Gulp tasks to get you started.