forked from huridocs/uwazi
-
Notifications
You must be signed in to change notification settings - Fork 1
/
api_test.js
59 lines (48 loc) · 1.42 KB
/
api_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
50
51
52
53
54
55
56
57
58
59
var exec = require('child_process').exec;
require('babel-core/register')(); //babel polyfill ES6
var mongoose = require('mongoose');
mongoose.Promise = Promise;
process.on('warning', (warning) => {
console.log(warning.name);
console.log(warning.message);
console.log(warning.stack);
});
var verbose = false;
if (process.argv[2] === '--v') {
verbose = true;
}
var Jasmine = require('jasmine');
var jasmine = new Jasmine();
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
//var customMatchers = require('./app/api/utils/jasmineMatchers.js');
//jasmine.getEnv().addMatchers(customMatchers);
var db_config = require('./app/api/config/database.js');
db_config.db_url = db_config.testing;
var elasticConfig = require('./app/api/config/elasticIndexes.js');
elasticConfig.index = elasticConfig.production;
jasmine.loadConfig({
spec_dir: 'app/',
spec_files: [
'api/**/*[sS]pec.js',
'shared/**/*[sS]pec.js'
],
helpers: [
'/api/utils/jasmineHelpers.js'
]
});
jasmine.addReporter(new SpecReporter({
spec: {
//displayStacktrace: 'summary',
displaySuccessful: verbose,
displayFailedSpec: true,
displaySpecDuration: true
}
}));
mongoose.connect('mongodb://localhost/uwazi_testing');
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function () {
mongoose.connection.db.dropDatabase(function () {
jasmine.execute();
});
});