forked from pantsel/konga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.test.js
49 lines (45 loc) · 1.31 KB
/
bootstrap.test.js
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
/**
* Mocha bootstrap file for backend application tests.
*/
var Sails = require('sails');
var fs = require('fs');
process.env.NODE_ENV = 'test';
/**
* Mocha bootstrap before function, that is run before any tests are being processed. This will lift sails.js with
* test configuration.
*
* Note! Tests will use localDiskDb connection and this _removes_ possible existing disk store file from .tmp folder!
*
* @param {Function} next Callback function
*/
before(function before(next) {
fs.unlink('.tmp/localDiskDb.db', function unlinkDone(error) {
Sails.lift({
// configuration for testing purposes
models: {
connection: 'localDiskDb',
migrate: 'drop'
},
port: 1336,
environment: 'test',
log: {
level: 'error'
},
hooks: {
grunt: false
}
}, function callback(error, sails) {
// Yeah sails is lifted now!
next(error, sails);
});
});
});
/**
* Mocha bootstrap after function, that is run after all tests are processed. Main purpose of this is just to
* lower sails test instance.
*
* @param {Function} next Callback function
*/
after(function after(next) {
sails.lower(next);
});