You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem: I have a tape test that compares strict equality of two objects. These objects have circular structure by design. If the test fails because the objects are not equal, tape-dom seems to be unable to render those objects and TypeError is thrown (see below). The JSON.stringify call is the source of the error.
Context: I have a tape test suite, which is bundled with webpack, and then ran in browser. I want to use tape-dom to render the test results on the page instead of console, in order to avoid opening the dev console every time. This worked fine until the problem above arose. I could bypass the problem by comparing some non-circular properties of those objects, but I feel it should not be necessary here in the case of strict equality comparison ===. Such bypass would probably be the best option for deepEqual assertions but not for strict.
Possible solution 1: in dom_consumer.js, catch TypeError, do not render the objects if they are problematic, and continue with the next assert.
Uncaught TypeError: Converting circular structure to JSON
--> starting at object with constructor 'HTMLDivElement'
| property 'affine' -> object with constructor 'Item'
--- property 'element' closes the circle
at JSON.stringify (<anonymous>)
at assertFailDiv (dom_consumer.js?6fa6:83:1)
at Stream.add_some_dom (dom_consumer.js?6fa6:137:1)
at Stream.emit (events.js?8416:153:1)
at drain (index.js?e6f0:36:1)
at stream.queue.stream.push (index.js?e6f0:45:1)
at Stream.write (index.js?e6f0:14:38)
at stream.write (index.js?e6f0:26:1)
at Stream.ondata (index.js?646e:53:1)
at Stream.emit (events.js?8416:153:1)
And finally, thanks for the package and any upcoming work and considerations regarding the issue.
The text was updated successfully, but these errors were encountered:
Problem: I have a tape test that compares strict equality of two objects. These objects have circular structure by design. If the test fails because the objects are not equal, tape-dom seems to be unable to render those objects and TypeError is thrown (see below). The JSON.stringify call is the source of the error.
Context: I have a tape test suite, which is bundled with webpack, and then ran in browser. I want to use tape-dom to render the test results on the page instead of console, in order to avoid opening the dev console every time. This worked fine until the problem above arose. I could bypass the problem by comparing some non-circular properties of those objects, but I feel it should not be necessary here in the case of strict equality comparison
===
. Such bypass would probably be the best option for deepEqual assertions but not for strict.Possible solution 1: in dom_consumer.js, catch TypeError, do not render the objects if they are problematic, and continue with the next assert.
Possible solution 2: in dom_consumer.js, replace JSON.stringify with a renderer that is able to handle circular structures. For example flatted might be a good candidate. See also this StackOverflow page for alternatives: https://stackoverflow.com/questions/11616630/how-can-i-print-a-circular-structure-in-a-json-like-format
Here is the error:
And finally, thanks for the package and any upcoming work and considerations regarding the issue.
The text was updated successfully, but these errors were encountered: