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

expect(undefined).to.be.defined behaving unexpectedly #955

Closed
mchandleraz opened this issue Apr 10, 2017 · 2 comments
Closed

expect(undefined).to.be.defined behaving unexpectedly #955

mchandleraz opened this issue Apr 10, 2017 · 2 comments

Comments

@mchandleraz
Copy link

This seems to be such an obvious bug that I feel like I'm missing something but I was following the typical "red-green-refactor" cycle of TDD and stumbled across a scenario where expect(undefined).to.be.defined was allowing a test to pass when used with Mocha. I've got a repo at https://github.com/mchandleraz/chai-wat that shows the issue.

I would expect a function that does not return anything to cause the 2nd test to fail (as the 3rd test does). Instead, only the 3rd test in my repo fails.

Have I found a bug, or is this expected?

Thanks!

@meeber
Copy link
Contributor

meeber commented Apr 10, 2017

Up until ES6 proxies, there was no way for Chai or Mocha to know that a non-existent property such as defined was chained off of an existing property like be. This problem is fixed in Chai v4 in ES6 compatible environments, currently available on npm via chai@canary. This and related issues are discussed in length in #726. Gonna close this issue due to duplication but please feel free to discuss in that thread.

@meeber meeber closed this as completed Apr 10, 2017
@mchandleraz
Copy link
Author

Thanks @meeber, I figured I was missing something.

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

No branches or pull requests

2 participants