JavaScript Basics

Just a page describing some basic notes on the JavaScript ecosystem.

Node

Server side javascript interpreter. Best off installing the latest one rather than trying tio rely and whatever is packaged with your system.

On Mint (a derivative of Ubuntu), you go here:

https://launchpad.net/~chris-lea/+archive/node.js/

I created the following file:

/etc/apt/sources.list.d/chris-lea-node_js-raring.list

and with the following contents:

deb http://ppa.launchpad.net/chris-lea/node.js/ubuntu raring main
deb-src http://ppa.launchpad.net/chris-lea/node.js/ubuntu raring main

NPM

This is the package manager. It comes with NodeJS. It lets you install other Javascript packages.

You can install things locally, or globally. Generally speaking the -g switch means global.

To see where stuff in installed:

npm root or npm root -g

To see what stuff you have installed:

npm list

That prints out a tree. To make it into just a list, use:

npm list --depth=0

Testing

Several choice but the popular ones seems to be

I've settled on Jasmine. It seems very similar to RSpec from the Ruby world. If you want to run Jasmine for backend tests, then you need jasmine-node. Quick way to run all the tests in a project:

jasmine-node spec --autotest --watch .

The "spec" tells you where you tests live. The watch option will watch the directory you specify, so in this case changes to both source and spec files will re-run all the tests. The autotest actually tells jasmine to watch the file system.

I sometimes like to run it like this:

jasmine-node spec --autotest --watch . --color --verbose

The color option will output passing tests in green and failing tests in red. The verbose option will give results for each test, not just the failing ones.

Karma

Karma appears to be a test runner centered on running tests in the browser (or, using PhantomJS, the command line). Useful for DOM tests, etc. Not sure how useful this is for simple node backend tests.

Grunt

Javascript task runner

Yeoman

Scaffolding tool. Basically involves installing a generator to scaffold the app.

yo angular 

to scaffold an agular app, but note that there is a bug whereby some plugins are not installed. You have to follow it with this:

npm install karma-jasmine --save-dev
npm install karma-chrome-launcher --save-dev

Bower

Front end package tool. See this:

http://stackoverflow.com/questions/18641899/difference-between-bower-and-npm

For a good discussion of the differences between bower and npm.

JavaScriptBasics (last edited 2014-04-14 23:50:06 by DesmondRivet)