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

Test output order incorrect when using loops #243

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

Test output order incorrect when using loops #243

gerukin opened this issue Apr 4, 2022 · 3 comments

Comments

@gerukin
Copy link

gerukin commented Apr 4, 2022

Given this test file:

{{
  module.exports = require('../../tests/')

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

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

{{
  tests.status.is(test, response, { val: 200 })
}}

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

{{_testBody}}

{{
  tests.status.is(test, response, { val: 400 })
}}

### 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}}

{{
  tests.status.is(test, response, { val: 200 })
}}

We get this result:
screenshot

Note: using version 5.3.0

@AnWeber
Copy link
Owner

AnWeber commented Apr 5, 2022

There is a general problem, how the loopMetaDataHandler currently works. With the commit from just now, it already works to some extent, but I can still figure out error sources. This currently requires special logic and also duplicates code from other hooks. I'll have to clean that up. That's why for example #242 doesn't work, because I forgot to add the necessary code to loopMetaDataHandler.

@AnWeber
Copy link
Owner

AnWeber commented Apr 21, 2022

By changing how the loopMetaDataHandler works in 7de5985, the error was corrected. This allowed me to remove some hacks. The logs should now be correct when executed. Thanks.

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

gerukin commented Apr 24, 2022

Works fine now, thanks!

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