Test frameworks
There are several different testing frameworks for JavaScript. So, if you have your own favorite testing framework, most of this advice would also apply to it. In this case, we will use Mocha. It is a fairly popular testing framework, so you can easily find many samples and examples on how to use it on the mochajs.org website. However, we will get you up and running with NativeScript. The first thing you need to do is open a terminal shell and install mocha
with the npm install –g mocha
command. The -g
option will tell npm
to install mocha
globally, just like we did when we installed the nativescript
command. By making it globally available, you can run it just by typing mocha
anywhere.
Note
Mocha is a JavaScript testing framework. This framework runs under node, so everything we are doing with the testing is all using node-based code. This might be confusing sometimes as JavaScript is simpler compared to NativeScript. So, even though we are loading and testing our code that...