[ mbtest ] mock server

run server

mb --configfile imposters.ejs --allowInjection

imposters.ejs

{
"imposters": [
,
]
}

originServer.ejs

{
"port": 5555,
"protocol": "http",
"name": "whatever",

"recordRequests": false,

"stubs": [
{
"predicates": [{
"equals": {
"method": "GET",
"path": "/whatever/whatever"
}
}],
"responses": [{ "is": { "body": "" }}]
},
{
"responses": [{ "inject": "function (request, state) { let d = []; for(let i=1; i <= 20; i++) { d.push({ title: `Pizza-${i}`, price: 99, address: 'lorem ipsum', ref: 'REST' }) }; return { body: d }; }" }]
}
]
}

ref : http://www.mbtest.org/docs/commandLine#config-file

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s