-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
76 lines (75 loc) · 2.72 KB
/
server.js
File metadata and controls
76 lines (75 loc) · 2.72 KB
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
const server = require('mockserver-node');
const client = require('mockserver-client').mockServerClient;
const port = 1080;
server
.start_mockserver({serverPort: port, verbose: true})
.then(
function() {
client('localhost', port).mockAnyResponse(
[
{
'httpRequest': {
'path': '/'
},
'httpResponse': {
'statusCode': 200,
'body': JSON.stringify({'bar': 'hola', 'foo': 'mundo'}),
'delay': {
'timeUnit': 'MILLISECONDS',
'value': 250,
}
}
},
{
'httpRequest': {
'path': '/foo'
},
'httpResponse': {
'statusCode': 200,
'body': JSON.stringify({'value': 'foo'})
}
},
{
'httpRequest': {
'path': '/bar'
},
'httpResponse': {
'statusCode': 200,
'body': JSON.stringify({'value': 'bar'})
}
},
{
'httpRequest': {
'path': '/foo-bar'
},
'httpResponse': {
'statusCode': 200,
'body': JSON.stringify({'value1': 'foo', 'value2': 'bar'})
}
},
{
'httpRequest': {
'method': 'GET',
'path': '/view/cart',
'queryStringParameters': {
'cartId': ['055CA455-1DF7-45BB-8535-4F83E7266092']
},
'cookies': {
'session': '4930456C-C718-476F-971F-CB8E047AB349'
}
},
'httpResponse': {
'body': 'some_response_body'
}
}
]
).then(
function () {
console.log('created expectations');
},
function (error) {
console.error(error);
}
)
}
)