Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Dec 20, 2022. It is now read-only.
Discussion options

Hello. Is there a more comprehensive documentation or detailed examples what is possible with the JS test feature? More specifically, I was thinking at least of

  • API doc for the client object used in tests
  • how does one run tests in external JS files
    • I saw the test_script.js file in sample repo but not how it's used
  • is it possible to import external libraries in tests?
    • related, is ESM supported
You must be logged in to vote

Replies: 1 comment · 1 reply

Comment options

Hi @tpluscode
Currently, the restcli supports JS test feature.
There are two ways to use JS test script.

  1. Embed

https://github.dev/restcli/restcli/blob/8dcdc30d5fdade75714173c7f4350514d53b1d58/src/test/resources/requests/requests-share-var-between-files2.http#L1-L9

### Share variable file2
GET https://httpbin.org/get?id={{my_variable}}
Content-Type: application/json

> {%
client.test("Request executed successfully", function() {
  client.log("my_variable: " + client.global.get("my_variable"));
});
 %}
  1. Use in the external file.
### Share variable file2
GET https://httpbin.org/get?id={{my_variable}}
Content-Type: application/json

> /path/to/test_script.js

is it possible to import external libraries in tests?

This is not supported yet. But if you have any ideas, please share them here.
Since I am not a Javascript expert, I need more research.

Thank you for the feedback!

You must be logged in to vote
1 reply
@tpluscode
Comment options

I opened #101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.