- in
/server-tests/
- tests of the REST API using http://jasmine.github.io/ - the tests are to be run on code from the same development branch (master, testing or experimental)
/server-nodejs/tests
- tests for the nodejs server using mocha
To get started, you need to install some modules in server-nodejs :
npm install mocha chai chai-as-promised supertest
Once mocha is started, every time you save modifications in a file the server is using, tests are made automatically
To get started, you need to install some modules in server-tests :
npm install
Edit conf-tests-frisby.json
as you need
To run tests, simply type the following command in the appropriate directory :
npm test
If you have this error :
/usr/bin/env: node: No such file or directory
then modify the shebang of the command (node_modules/{moduleName}/bin/{moduleName}) to #!/usr/bin/env
nodejs
or create an alias node
-> nodejs
Fun fact : Mocha did a really strange thing : it changes 'Foo'
into {Foo:''}
when it is sent in POST
Anyway, the priority is now given to Jasmine/Frisby.
The latter is now testing Create, Read, Update, Delete, Graph, Lock, Unlock.
It revealed that:
- Read and Graph returns a non empty array, the parameter is not found.
- Read in POST needs an object which contains the key
id
as parameter - Lock and Unlock make server crash if parameter is not found
- Delete doesn't throw the right errors
Abstract: as we start a new coding session with teammates we want to stick to a reference as explained in the issue #99.
We mainly want to stick to the Crockford document. It will become our reference for this list:
- Variable Declaration
- indentation: 4 spaces
- 2 line return at the end of file
http://javascript.crockford.com/code.html
if (null == variable) {
return null;
} else if ('test' !== variable) {
return false;
} else {
// code...
}
-
When appliable, check the constant value before the variable. It allows for more visibility in the code, and prevents unwanted assignments.
-
For multiple conditions, put the next one on the same line as the last closing bracket.
-
Use the strict equality check
===
, except when we want to test for equivalent values. -
Always use braces and put the instructions on a new line. Even for single-line conditions containing a return statement. This way we can insert new instructions within the same condition without modifying existing lines.
var i = 0;
var maximumValue = list.length;
i = 1;
i += 2;
-
Always use the
var
keyword for each variable. -
Don't vertically align operators, unless you do so for the same variable ; this way the lines are not dependent.