mirror of
https://github.com/usebruno/bruno.git
synced 2025-08-02 02:22:56 +02:00
* wip: code cleanup, added axios, nanoid shims for quickjs vm * wip: test fn fix * wip: scrip exec fix * wip: added node-fetch & uuid shims
37 lines
642 B
Plaintext
37 lines
642 B
Plaintext
meta {
|
|
name: node-fetch-pre-req-script
|
|
type: http
|
|
seq: 1
|
|
}
|
|
|
|
get {
|
|
url: {{host}}/ping
|
|
body: none
|
|
auth: none
|
|
}
|
|
|
|
script:pre-request {
|
|
const fetch = require("node-fetch");
|
|
|
|
const url = "https://testbench-sanity.usebruno.com/api/echo/json";
|
|
const response = await fetch(url, {
|
|
method: 'post',
|
|
body: JSON.stringify({hello:'bruno'}),
|
|
headers: {'Content-Type': 'application/json'}
|
|
});
|
|
|
|
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"
|
|
});
|
|
});
|
|
|
|
}
|