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(...).to.be.ok and .to.be.defined/undefined etc should be able to take custom Assertion Error messages #558

Closed
JaKXz opened this issue Nov 27, 2015 · 3 comments

Comments

@JaKXz
Copy link

JaKXz commented Nov 27, 2015

It would be awesome to be able to specify custom Assertion error messages for the .to.be.ok and to.be.defined/.to.be.undefined etc checks that don't currently allow this (AFAIK ATM, please correct me if I'm wrong!)

It would allow me to write more readable tests instead of having to do things like:

expect(!!someObj.someProp).to.equal(true, 'someProp should be defined/truthy/etc');

just to get the custom Assertion message.

@keithamus
Copy link
Member

Hey @JaKXz thanks for the issue.

We tried to do something this a while ago - but having functions and getters did not work sadly.

If you want the history you can see #41, #297, #302, #306, #321, #326 and probably some others I've missed.

The problem is that this is a tough one to solve without huge breaking changes, or a whole new interface. Take a look at the roadmap (#457) which is a bit of a long path towards eventually solving this kind of problem.

I'll close this for now, because it's something that is inherent in the design requirements for newer versions of chai. If you want to follow the progress, then I suggest you subscribe to #457 😄

@JaKXz
Copy link
Author

JaKXz commented Nov 27, 2015

Thanks @keithamus, I wasn't exactly sure of how to phrase my search to find those issues. I do realize of course that this isn't trivial and I figured I'd ask to get the story.

Perhaps ES2015 Proxy can help? I'll take a look at #457, thanks again.

@keithamus
Copy link
Member

We've had a look at ES2015 proxies, and I think they can help in some ways, but I dont think this will be one of the ways. If you want to see the proxy discussion, have a look at #407.

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