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

wild-card in Expr to assert all Array-Values #3918

Open
1 task done
true-false-maybe opened this issue Jan 31, 2025 · 0 comments
Open
1 task done

wild-card in Expr to assert all Array-Values #3918

true-false-maybe opened this issue Jan 31, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@true-false-maybe
Copy link

I have checked the following:

  • I've searched existing issues and found nothing related to my issue.

Describe the feature you want to add

I have no idea how hard it would be, but it would be nice to write an assert like this:

Expr Operator Value
res.body isArray
res.body[*] isString
res.body[*] isNotEmpty

or in the .bru file:

...

assert {
  res.body: isArray
  res.body[*]: isString
  res.body[*]: isNotEmpty
}

The idea is to check that all values in an array are strings, just with assertions. Or any of the other operators which currently exist.

Responses which would pass would be:

[]
["abc"]
["abc", "def"]

Responses which wouldn't pass would be:

["abc", 123]
[123]
[null]
[{}]

The edge-case when the array is empty should always pass, since one can simply add another assertion that the array is not empty.

Mockups or Images of the feature

For simple arrays:

Expr Operator Value
res.body[*] isString

or in the .bru file:

...

assert {
  res.body[*]: isString
}

Nice-to-have would be further nesting like res.body[*][*] or res.body[*].values[*]

The error message for a fail could be the first value which failed, or something similar.

@true-false-maybe true-false-maybe added the enhancement New feature or request label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant