mirror of
https://github.com/usebruno/bruno.git
synced 2025-02-18 02:30:58 +01:00
feat: safe mode updates
This commit is contained in:
parent
c687856a9e
commit
3b3fa8a856
@ -0,0 +1,34 @@
|
|||||||
|
meta {
|
||||||
|
name: axios-pre-req-script
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: {{host}}/ping
|
||||||
|
body: none
|
||||||
|
auth: none
|
||||||
|
}
|
||||||
|
|
||||||
|
script:pre-request {
|
||||||
|
const axios = require("axios");
|
||||||
|
|
||||||
|
const url = "https://testbench-sanity.usebruno.com/api/echo/json";
|
||||||
|
const response = await axios.post(url, {
|
||||||
|
"hello": "bruno"
|
||||||
|
});
|
||||||
|
|
||||||
|
req.setBody(response.data);
|
||||||
|
req.setMethod("POST");
|
||||||
|
req.setUrl(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
tests {
|
||||||
|
test("req.getBody()", function() {
|
||||||
|
const data = res.getBody();
|
||||||
|
expect(data).to.eql({
|
||||||
|
"hello": "bruno"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
32
packages/bruno-tests/collection/scripting/js/setTimeout.bru
Normal file
32
packages/bruno-tests/collection/scripting/js/setTimeout.bru
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
meta {
|
||||||
|
name: setTimeout
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: {{host}}/ping
|
||||||
|
body: none
|
||||||
|
auth: none
|
||||||
|
}
|
||||||
|
|
||||||
|
script:pre-request {
|
||||||
|
bru.setVar("test-js-set-timeout", "");
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
bru.setVar("test-js-set-timeout", "bruno");
|
||||||
|
resolve();
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
|
const v = bru.getVar("test-js-set-timeout");
|
||||||
|
bru.setVar("test-js-set-timeout", v + "-is-awesome");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
tests {
|
||||||
|
test("setTimeout()", function() {
|
||||||
|
const v = bru.getVar("test-js-set-timeout")
|
||||||
|
expect(v).to.eql("bruno-is-awesome");
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user