Skip to content

File.toString vs native #174

New issue

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

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

Already on GitHub? # to your account

Open
joscha opened this issue Jul 31, 2024 · 1 comment
Open

File.toString vs native #174

joscha opened this issue Jul 31, 2024 · 1 comment

Comments

@joscha
Copy link

joscha commented Jul 31, 2024

I just used fetch-blob in one of my projects and I noticed in snapshot tests that the string representation of the File class here is simplified in contrast to the native one:

Screenshot 2024-07-31 at 5 21 33 PM

It seems to be deliberate, as there is a test covering it:

test( // Because browser normally never tries things taken for granted
() => assert_equals(new File([], '').toString(), '[object File]'),
'file.toString() returns [object File]'
)

The way the snapshot tests representations are constructed are not from .toString() but from what is usually printed in the console: https://github.com/denoland/std/blob/b213d54732282e3f635fd7e3535348b3af92e4c2/testing/snapshot.ts#L215-L226

I am not completely sure yet, where to start, as I previously had assumed string representation to be always the same as .toString() but I was wondering if you'd consider accepting a change that would keep the current behaviour for .toString() but changes it for a console print, similar to what Chrome does:

Screenshot 2024-07-31 at 5 42 36 PM

which I am assuming would be what Deno.inspect would do as well.

@jimmywarting
Copy link
Contributor

i assume you would use the "custom symbol inspect" for that? i'm fine with a PR for that

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

No branches or pull requests

2 participants