question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot console.log assertions because of proxies

See original GitHub issue

Consider:

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:

  1. meep

0 passing (13ms) 1 failing

  1. 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
meebercommented, Aug 12, 2016

@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)

2reactions
keithamuscommented, Aug 6, 2016

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 ❤️

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found