-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
54 lines (24 loc) · 1.13 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Writing tests is simple an easy with Ernest!
Example:
Start by requiring the Ernest module. Path may need to be altered depending on location of test files.
var ernest = require(‘geddy/geddy-core/scripts/ernest’);
var assert = require('assert);
Create an namespace (object-literal) to wrap your tests.
var myTests = {
//preface each key with the word ‘test’
testThatSomethingWorks : function(){
var foo = ‘bar’;
//use Node’s Assert module — last parameter is fail message that is displayed.
//By default, it uses what’s predefined in Ernest
assert.ok(foo, this.fail);
assert.equal(foo, ‘bar’, this.fail);
}
};
And, for the last bit, pass your new test to Ernest:
ernest.execute(myTests);
If you want tests to be run via ‘make test’ — Save your tests in a directory called ‘tests’ in the module you’re testing.
That’s it!!! It’s that easy!
Tests can be run one of two ways:
run all tests: make test
individual tests: node path/to/test.js
Additionally I've included an example of tests that are actively being used in Geddy (http://www.github.com/mde/geddy).