Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request count incorrect when using loops #242

Closed
gerukin opened this issue Apr 4, 2022 · 2 comments
Closed

Request count incorrect when using loops #242

gerukin opened this issue Apr 4, 2022 · 2 comments

Comments

@gerukin
Copy link

gerukin commented Apr 4, 2022

Given this request file:

{{
  const body = { id: '{{$guid}}', hello: 'world' }
  module.exports._testBody = body
  module.exports._propertiesToRemove = Object.keys(body)
}}

### Test 1
https://httpbin.org/status/200

### Test 2
POST https://httpbin.org/post
Content-Type: application/json

{{_testBody}}

### Test 3 (bug)
# @loop for property of _propertiesToRemove
{{
  const body = { ..._testBody }
  delete body[property]
  module.exports._bodyWithPropertyRemoved = body
}}
POST https://httpbin.org/post
Content-Type: application/json

{{_bodyWithPropertyRemoved}}

Running this command:

httpyac --all ./requests/bugs --output short

We get the following:

---------------------

=== Test 1 ===

GET https://httpbin.org/status/200
=> 200 (1405 ms, 184 B)

---------------------

=== Test 2 ===

POST https://httpbin.org/post
=> 200 (539 ms, 696 B)

---------------------

=== Test 3 (bug) ===

POST https://httpbin.org/post
=> 200 (706 ms, 651 B)

---------------------

=== Test 3 (bug) ===

POST https://httpbin.org/post
=> 200 (573 ms, 653 B)

3 requests tested (3 succeeded, 0 failed)

Note the 3 succeeded counter, when in fact Test 3 was executed twice (as expected).

🪙 suggestion

It could also be nice to be able to use variables in title / description comments. 🤔 Like:

### Test 3 (removing {{property}})

Right now I use a console log instead, but it isn't nearly as clean, and isn't included in the json output.

@AnWeber
Copy link
Owner

AnWeber commented Apr 21, 2022

This bug was also fixed with commit 7de5985. Now the interceptors are executed correctly and I was able to remove some hacks from the LoopMetaDataHandler. Is released with v5.4.0. Sorry it took a few days now. I needed a break from the PC.

@AnWeber AnWeber closed this as completed Apr 21, 2022
@gerukin
Copy link
Author

gerukin commented Apr 24, 2022

Thanks, works fine on my end now!

I needed a break from the PC.

Don't we all! Appreciate your taking the time. 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants