-
-
Notifications
You must be signed in to change notification settings - Fork 698
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
Typed Arrays not truncated #441
Comments
Thanks for the issue @jwagner, I also completely agree. Right now, all code for object inspection lives in lib/chai/utils/inspect.js (I say "right now", because there are plans to finally migrate it over into https://github.com/chaijs/loupe). To add support for Typed Arrays should be reasonably easy to fix. If I were to fix this, I'd simply create a function called Of course you'd need to add some good tests to ensure good coverage of this, and add guards to make sure engines without typed arrays do not blow up when trying to reference them. Tests for the inspect util are found in test/utilities.js#l355-375 |
Hi @keithamus, I'm planning on tackling this one. Would you mind if I opened a pull request tagged as [WIP] so you guys can review, approve/disapprove my changes? |
@lucasfcosta absolutely feel free to raise it under a [WIP] PR! |
Hi @keithamus, I've done some progress and I'd like to confirm if my PR has acceptable code to solve this before refactoring it. As I've said before, the PR is still tagged as WIP because I plan on refactoring it after you guys approve its behavior. |
Hi @keithamus, this one is done, I think we can close it 😄 |
Ah, thanks @lucasfcosta 😄 |
Chai does currently not handle typed arrays very well:
http://jsfiddle.net/7LbaveL6/
Typed Arrays have various uses but are usually big blobs of data (for example from canvas getImageData).
The problem with the way they are currently handled is that it causes the page to freeze when assertions are run on objects containing bigger typed arrays.
I looked at the code but wasn't sure where the right place for a fix would be.
In my opinion it would be ok to just output the to String representation of the typed array (by treating it like a primitive), but it could also use the array code path with proper truncation.
The text was updated successfully, but these errors were encountered: