-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
"defined" is not a magic Chai method #9707
Comments
This is so bad. Could be fixed with something like const handler = {
get: function(target, name) {
if (Object.getOwnPropertyDescriptor(target, name)) {
return target[name];
}
throw new Error('Unsupported property: ' + name)
}
};
new Proxy(chaiPrototype, handler); |
Apparently they do exactly this in Chai 4.0.0. |
@jridgewell This can be solved in the following ways:
1 will solve the problem and prevent future misuse, but isn't elegant. 2 will add useful functionality, but won't prevent the use of the antipattern. I don't think 3 will work with the rest of our testing stack. Thoughts? |
I think 3 is the only appropriate answer. Defining |
Fair point. There's a cascading chain of dependencies that will need to be upgraded to get to |
The upgrade to chai 4 has exposed several nasty bugs in the AMP test code. Luckily, fixes for all of them are coming up in #11390. Stay tuned. |
This is now fixed via an upgrade to chai 4, along with many other bogus assertions that were silently passing. |
Have I ever mentioned how much I hate chai's magic property-access getter method bulllshit?
.defined
is not a Chai method. But because it uses stupid getter API (and not real methods), you'd never know it.Instead, any sane API would use real methods
The text was updated successfully, but these errors were encountered: