-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdumpinator.conf.js
118 lines (106 loc) · 2.13 KB
/
dumpinator.conf.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
'use strict';
const path = require('path');
const co = require('co');
const colorfy = require('colorfy');
const Dumpinator = require('./src/dumpinator');
let ps1;
let ps2;
function startApp(cwd, port) {
colorfy()
.yellow('dp start app at port')
.lgrey(port)
.txt('in dir')
.azure(cwd)
.print();
const env = process.env;
env.PORT = port;
return Dumpinator.runShellTask('node', ['examples/server.js'], {
cwd,
env,
listenFor: [
'Server listen at port'
]
}).then((ps) => {
colorfy()
.yellow(' ... started with pid')
.lgrey(ps.pid)
.print();
return ps;
});
}
function installApp(cwd) {
return Dumpinator.runShellTask('npm', ['install'], {
cwd
});
}
function killProcess(ps) {
colorfy()
.yellow('dp kill process')
.lgrey(ps.pid)
.print();
ps.kill();
}
module.exports = {
defaults: {
left: {
hostname: 'http://localhost:3100'
},
right: {
hostname: 'http://localhost:3200'
},
status: 200,
ignoreBody: [
'properties.price',
'properties.age'
],
ignoreHeader: [
'etag',
'last-modified',
'date',
'x-date'
]
},
routes: [
{
url: '/v1/test.json',
tag: 'test',
before() {
},
after() {
}
}, {
url: '/v2/test.json',
tag: 'test',
status: 204
}, {
tag: 'banana',
left: {
url: '/v1/banana.json'
},
right: {
url: '/v2/banana.json'
}
}
],
before() {
return co(function* g() {
yield installApp(path.join(process.cwd(), '.dumpinator-tmp/left/'));
yield installApp(path.join(process.cwd(), '.dumpinator-tmp/right/'));
ps1 = yield startApp(path.join(process.cwd(), '.dumpinator-tmp/left/'), 3100);
ps2 = yield startApp(path.join(process.cwd(), '.dumpinator-tmp/right/'), 3200);
});
},
after() {
killProcess(ps1);
killProcess(ps2);
},
beforeEach() {
console.log('Before each'); // eslint-disable-line no-console
},
afterEach() {
console.log('After each'); // eslint-disable-line no-console
},
transform(data) {
return data;
}
};