feat: safe mode updates

This commit is contained in:
Anoop M D 2024-08-12 13:10:21 +05:30
parent c687856a9e
commit 3b3fa8a856
2 changed files with 66 additions and 0 deletions

View File

@ -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"
});
});
}

View 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");
});
}