eykrehbein / strest

⚡️ CI-ready tests for REST APIs configured in YAML
MIT License
1.74k stars 59 forks source link

View variable information when using the `-p` switch #123

Open jdm-hexagon opened 5 years ago

jdm-hexagon commented 5 years ago

Is your feature request related to a problem? Please describe. I'd like to be able to see the contents of a set variable. e.g: In relation to #122 I'm pulling the token from the previous request and using it in the next as a header value.

      headers:
        - name: x-device-auth
          value: <$ login.content.Result.token | dump | safe $>

This should be working, but no. Being able to view the processed variable will help with debugging.

Describe the solution you'd like When using the strest -p switch, can it output the request headers and body, not just the response?

Not sure if I'm missing something here

jgroom33 commented 5 years ago

As a workaround, I've been sending values to the postman-echo api or some other api that sends back responses

jgroom33 commented 5 years ago

This is probably related to #111 There should be a better report structure for output. This is a more complete use of the har format:

{
  "log": {
    "entries": [
      {
        "startedDateTime": "2019-02-19T04:34:33.266Z",
        "time": 20.55699983611703,
        "request": {
          "method": "GET",
          "url": "https://jsonplaceholder.typicode.com/posts?userId=1&id=3",
          "httpVersion": "http/2.0"
        },
        "response": {
          "status": 304,
          "content": {
            "size": 299,
            "mimeType": "application/json",
            "text": "[\n  {\n    \"userId\": 1,\n    \"id\": 3,\n    \"title\": \"ea molestias quasi exercitationem repellat qui ipsa sit aut\",\n    \"body\": \"et iusto sed quo iure\\nvoluptatem occaecati omnis eligendi aut ad\\nvoluptatem doloribus vel accusantium quis pariatur\\nmolestiae porro eius odio et labore et velit aut\"\n  }\n]"
          }
        },
        "timings": {
          "blocked": 2.404000018924475,
          "send": 0.11799999999999988,
          "wait": 17.691999999389054,
          "receive": 0.3429998178035021,
          "_blocked_queueing": 1.1950000189244747
        }
      }
    ]
  }
}

I suggest we use a dict with testName instead of an array as the standard uses. This would keep the nunjucks references simple.

Implementation option 1 (breaking change): <$ testName.response.content.userId $>

Implementation option 2: <$ testName.request.content.foo $> <$ testName.content.userId $> <-- does not change current behavior