User:Roger Pearse/JavaScript Basics

From Encyclopedia of Syriac Literature
Jump to navigationJump to search

Installing stuff with NPM

Start any node.js project by:

mkdir MyProject
cd MyProject
echo {} >> package.json

Install tools into the project using:

npm install karma --save-dev
<pre>

Rather than globally with 

<pre>
npm install karma -g 

because then you aren’t dependent on local configuration.

What’s –save-dev? That’s an option that updates the installed packages in the ‘devDependencies’ section of the package.json file. It signifies that a developer will need this package to work with the application, but it’s not required to run the applicaiton i.e. in production.

http://www.bradoncode.com/blog/2015/05/19/karma-angularjs-testing/

Path problem in Windows

If you find that stuff installed with npm is not in the path in git bash, this means that when node was installed, the idiot didn't install as administrator, and the path stuff ended up in his local environment variables, rather than in the system environment variables. Might be able to fix via Windows | env, manually. Otherwise deinstall node from Control Panel, and reinstall.

Editor

Getting started with VS Code


Nodes.js

Unit Testing

Mocha seems to have the lead...

Mocking

Use Sinon instead of Mockito. There’s a before() and after() function. Stub the xhtmlrequest calls.