Skip to content
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

Flag transfer problem in failed .include assertion #904

Closed
meeber opened this issue Jan 16, 2017 · 1 comment
Closed

Flag transfer problem in failed .include assertion #904

meeber opened this issue Jan 16, 2017 · 1 comment

Comments

@meeber
Copy link
Contributor

meeber commented Jan 16, 2017

Proxy-related frames are showing up in the stack trace for the .include assertion when testing for a subset of properties in an object. Also, custom error messages aren't being displayed in this case.

Example:

expect({x: {a: 1}}).to.include({x: {x: 9}}, "oh noooo");

Output:

  AssertionError: expected { x: { a: 1 } } to have property 'x' of { x: 9 }, but got { a: 1 }
  + expected - actual

   {
  -  "a": 1
  +  "x": 9
   }

  at Proxy.<anonymous> (node_modules/chai/lib/chai/core/assertions.js:322:25)
  at Array.forEach (native)
  at Proxy.include (node_modules/chai/lib/chai/core/assertions.js:317:13)
  at Proxy.chainableMethodWrapper (node_modules/chai/lib/chai/utils/addChainableMethod.js:93:49)
  at Context.<anonymous> (test/index.js:8:26)

I suspect both problems are a lack of flags being transferred to the .property assertion that the .include assertion calls internally. Will investigate later, just noting for now.

@meeber
Copy link
Contributor Author

meeber commented Jan 28, 2017

Just realized this problem is much more widespread than .include, and predates the proxy stuff. Basically, any assertion that creates another assertion internally isn't going to filter out Chai's implementation frames correctly. This happens to be the exact same root problem as described here regarding the assert interface, so an ideal solution would fix that occurrence of the problem too.

I think expanding the usage of the already existing keep_ssfi flag will do the trick. Working on a PR.

Also, most assertions aren't always passing along a user's custom error message either, but this isn't exactly the same problem. Will solve separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants