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

Test passes when the thing after "to.be" is nonsense #549

Closed
hoegrammer opened this issue Nov 9, 2015 · 2 comments
Closed

Test passes when the thing after "to.be" is nonsense #549

hoegrammer opened this issue Nov 9, 2015 · 2 comments

Comments

@hoegrammer
Copy link

describe('when writing tests using to.be', function() {
  it('passes when mispelled', function() {
    expect(true).to.be.flase;
  });
});
@hoegrammer
Copy link
Author

Actually it's not just after to.be. This also passes:

expect(true).footle;

Although this throws property-of-undefined:

expect(true).footle.bzzzzz;

@keithamus
Copy link
Member

Hi @hoegrammer, thanks for the issue.

This is a well known issue, and has been discussed a few times. If you want the history you can see #41, #297, #302, #306, #321, #326 and probably some others I've missed.

For ways we're actually planning to solve this problem, please have a look at our Roadmap in #457, and more specifically #407 - where we discuss adding proxies which would let us throw errors on undefined properties.

If you need a fix right now, then you have two options:

  1. Don't use the property getters, instead use method alternatives, e.g. expect(true).to.equal(false);
  2. Use dirty-chai which rewrites all of those property assertions to method assertions, so expect(true).to.be.false becomes expect(true).to.be.false().

We'd love to get some help on making #407 a reality, so if you'd like to continue the discussion there, or perhaps make a pull request, that'd be awesome 😄

I'm closing this, given that it's a duplicate of all of the above mentioned issues.

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