mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-16 04:11:29 +00:00
~ add bru.runRequest support for cli ~ add bru.runner.skipRequest, bru.runner.stopExecution support for cli
97 lines
1.9 KiB
Plaintext
97 lines
1.9 KiB
Plaintext
meta {
|
|
name: runRequest
|
|
type: http
|
|
seq: 2
|
|
}
|
|
|
|
post {
|
|
url: {{host}}/api/echo/json
|
|
body: json
|
|
auth: none
|
|
}
|
|
|
|
headers {
|
|
foo: bar
|
|
}
|
|
|
|
auth:basic {
|
|
username: asd
|
|
password: j
|
|
}
|
|
|
|
auth:bearer {
|
|
token:
|
|
}
|
|
|
|
body:json {
|
|
{
|
|
"hello": "bruno"
|
|
}
|
|
}
|
|
|
|
assert {
|
|
res.status: eq 200
|
|
}
|
|
|
|
script:pre-request {
|
|
bru.setVar("runRequest-ping-res-1", null);
|
|
bru.setVar("runRequest-ping-res-2", null);
|
|
bru.setVar("runRequest-ping-res-3", null);
|
|
|
|
let pingRes = await bru.runRequest('ping');
|
|
bru.setVar('runRequest-ping-res-1', {
|
|
data: pingRes?.data,
|
|
statusText: pingRes?.statusText,
|
|
status: pingRes?.status
|
|
});
|
|
}
|
|
|
|
script:post-response {
|
|
let pingRes = await bru.runRequest('ping');
|
|
bru.setVar('runRequest-ping-res-2', {
|
|
data: pingRes?.data,
|
|
statusText: pingRes?.statusText,
|
|
status: pingRes?.status
|
|
});
|
|
}
|
|
|
|
tests {
|
|
const pingRes = await bru.runRequest('ping');
|
|
bru.setVar('runRequest-ping-res-3', {
|
|
data: pingRes?.data,
|
|
statusText: pingRes?.statusText,
|
|
status: pingRes?.status
|
|
});
|
|
|
|
test("should run request and return valid response in pre-request script", function() {
|
|
const expectedPingRes = {
|
|
data: "pong",
|
|
statusText: "OK",
|
|
status: 200
|
|
};
|
|
const pingRes = bru.getVar('runRequest-ping-res-1');
|
|
expect(pingRes).to.eql(expectedPingRes);
|
|
});
|
|
|
|
test("should run request and return valid response in post-response script", function() {
|
|
const expectedPingRes = {
|
|
data: "pong",
|
|
statusText: "OK",
|
|
status: 200
|
|
};
|
|
const pingRes = bru.getVar('runRequest-ping-res-2');
|
|
expect(pingRes).to.eql(expectedPingRes);
|
|
});
|
|
|
|
test("should run request and return valid response in tests script", function() {
|
|
const expectedPingRes = {
|
|
data: "pong",
|
|
statusText: "OK",
|
|
status: 200
|
|
};
|
|
const pingRes = bru.getVar('runRequest-ping-res-3');
|
|
expect(pingRes).to.eql(expectedPingRes);
|
|
});
|
|
|
|
}
|