Difference between revisions of "User:Roger Pearse/JavaScript Basics"
Roger Pearse (talk | contribs) |
Roger Pearse (talk | contribs) |
||
Line 1: | Line 1: | ||
= Installing stuff with NPM = | = Installing stuff with NPM = | ||
+ | |||
+ | == Starting a new node project == | ||
Start any node.js project by: | Start any node.js project by: | ||
Line 26: | Line 28: | ||
http://www.bradoncode.com/blog/2015/05/19/karma-angularjs-testing/ | http://www.bradoncode.com/blog/2015/05/19/karma-angularjs-testing/ | ||
+ | |||
+ | == Starting the project 2 == | ||
+ | |||
+ | Npm's init command line option will launch a wizard, which creates a package.json for our project. | ||
+ | |||
+ | <pre> | ||
+ | npm init | ||
+ | </pre> | ||
+ | |||
+ | Do this after creating the directory. | ||
== Path problem in Windows == | == Path problem in Windows == | ||
Line 53: | Line 65: | ||
Mocha seems to have the lead... | Mocha seems to have the lead... | ||
+ | |||
+ | == Jasmine = BDD == | ||
+ | |||
+ | * Jasmine quick start – excellent - http://www.bradoncode.com/blog/2015/05/12/angularjs-testing-getting-started/ | ||
+ | |||
== Mocking == | == Mocking == | ||
Use Sinon instead of Mockito. There’s a before() and after() function. Stub the xhtmlrequest calls. | Use Sinon instead of Mockito. There’s a before() and after() function. Stub the xhtmlrequest calls. |
Revision as of 13:52, 4 July 2017
Contents
Installing stuff with NPM
Starting a new node project
Start any node.js project by:
mkdir MyProject cd MyProject echo {} >> package.json
Install tools into the project using:
npm install karma --save-dev
Rather than globally with
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/
Starting the project 2
Npm's init command line option will launch a wizard, which creates a package.json for our project.
npm init
Do this after creating the directory.
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
- Great little tutorial! – add to basics - VS Code is the editor to use.
Nodes.js
Express
MVC framework built on Node. Has an express generator that will build the project dirs.
.... insert here ....
Unit Testing
Mocha seems to have the lead...
Jasmine = BDD
- Jasmine quick start – excellent - http://www.bradoncode.com/blog/2015/05/12/angularjs-testing-getting-started/
Mocking
Use Sinon instead of Mockito. There’s a before() and after() function. Stub the xhtmlrequest calls.