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

JSON.stringify() does not play well #138

Closed
AuHau opened this issue Oct 10, 2020 · 1 comment · Fixed by #281
Closed

JSON.stringify() does not play well #138

AuHau opened this issue Oct 10, 2020 · 1 comment · Fixed by #281
Labels
bug Something isn't working
Milestone

Comments

@AuHau
Copy link

AuHau commented Oct 10, 2020

Describe the bug
When calling JSON.stringify on Substitute I will receive undefined. While I understand that it is hard to decide what should be returned I would expect at least something and not undefined.

I think that the toJSON() function could be employed here to define some behavior.

To Reproduce

interface Obj {
	hello: string
}
const sub = Substitute.for<Obj>()
sub.hello.returns('world')
JSON.stringify(sub) // undefined
@notanengineercom
Copy link
Collaborator

I was able to reproduce it. Makes sense 👍
Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants