Cannot console.log assertions because of proxies
See original GitHub issueConsider:
const {expect} = require("chai");
it("meep", () => {
const myAssertion = expect(42).to.equal(42);
console.log(myAssertion);
});
In Chai v3.5, the output is:
Assertion { __flags: { ssfi: [Function], object: 42, message: undefined } } ✓ meep
1 passing (25ms)
But in the current version of Chai off Github, the output is:
- meep
0 passing (13ms) 1 failing
- meep: Error: Invalid Chai property: inspect at Error (native) at Object.getProperty [as get] node_modules/chai/lib/chai/utils/proxify.js:30:15 at formatValue (util.js:343:19) at inspect (util.js:198:10) at exports.format (util.js:75:24) at Console.log (console.js:43:37) at Context.it (test/index.js:6:11)
Possible solution:
Add inspect
as a blacklisted property here. then
already exists as a blacklisted property for promise support. inspect
is a standard property in Node, as noted in https://github.com/chaijs/chai/issues/727#issuecomment-225373838.
Rather than hard-coding the blacklist, it might be more appropriate to refactor the blacklist to be a new Chai config value.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Why does console.log not trigger proxy getter trap?
That's because you are logging the Proxy object itself. The browser console has access to its internal state, which is an Object with...
Read more >Metaprogramming with Proxies • Deep JavaScript - Exploring JS
Meta level for (const key of Object.keys(obj)) { console.log(key); } ... by Proxies, we have a problem: things fail, because different information is ......
Read more >console.assert() - Web APIs | MDN
The console.assert() method writes an error message to the console if the assertion is false. If the assertion is true, nothing happens.
Read more >Avoid Proxy objects in debug statements for a Lightning ...
Basically I want my console.log statements to show all the good stuff instead of the LockerService Proxy object. Is there a way to...
Read more >Edge Microgateway error reference - Apigee Docs
Type Message Handler
error org is required assert
error env is required assert
error username is required assert
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@lucasfcosta Welcome back sir. You’ve been missed.
NOW GET TO WORK 😄
AND ABSOLUTELY NO MORE VACATIONS EVER
(By the way, @keithamus @lucasfcosta, I’ll be on vacation with limited connectivity Aug 18th - Sept 4th)
Just wanna say btw, aside from this ticket, thank you for being an awesome chai maintainer! It really shows that you care and thats super important. You’re my hero ❤️