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

Fails to encode results to json due to non-string error objects being raised #729

Open
svermeulen opened this issue Sep 16, 2023 · 4 comments

Comments

@svermeulen
Copy link
Contributor

I have a custom error table that I pass to error(foo). When I do this in a busted test, and then pass --output=json, it will just print nothing, due to an error that occurs in json.encode where it is unable to serialize function objects. I'm guessing that busted should run tostring(error_obj) somewhere to address this problem

@YaroSpace
Copy link

Reopening the issue:
I am getting Failed to encode test results to json: type 'function' is not supported by JSON when running a suite with pending tests. Pending tests have an attribute - default_fn which is a function (defined as function() end in busted `init.lua:71', that cannot be encoded into json.

@alerque
Copy link
Member

alerque commented Nov 21, 2024

PRs welcome. Just papering over this with tostring() is probably not going to help though because comparing the string ID for two functions (even with identical content) is going to turn up !=. Some extra consideration might be needed.

@YaroSpace
Copy link

Ok. Will investigate further)

@YaroSpace
Copy link

I have a custom error table that I pass to error(foo). When I do this in a busted test, and then pass --output=json, it will just print nothing, due to an error that occurs in json.encode where it is unable to serialize function objects. I'm guessing that busted should run tostring(error_obj) somewhere to address this problem

@svermeulen I know it has been a while, but can you tell me how to reproduce your issue? I am trying to pass a custom error object to error(), but I am not getting any problems.

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

No branches or pull requests

3 participants