chai: Error on strict mode

I got this error with the code expect(value).to.be.null that run on strict mode. chai-error-strict-mode

P/s. I’m using chai@3.4.1 installed via npm install chai.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 23 (11 by maintainers)

Most upvoted comments

Hey @lucasfcosta, I’m not sure I understand this. What is exactly the final decision then? I think the arguments.callee still should be replaced with:

flag(this, 'ssfi', stack || Assertion)

The only thing I wouldn’t include is the 'use strict'; part on the top of every file. This way no bugs would be introduced, everything would still work as expected and lazy people like me could use --use_strict without any error message.

I checked a few things and I think it might be best if the 'use strict'; were not included. http://stackoverflow.com/questions/16871050/inconsistent-scope-of-use-strict-on-different-web-browsers-concerning-argumen The linked jsfiddle fails in Firefox, so if somebody extends chai in some weird way it could cause problems for them.

Long term we’ll be splitting out most of the code here into separate modules, at which point they’ll all be tidied up and very likely have the 'use strict' stanza. So it’s essentially inevitable that all chai code will be strict mode code.

Having said that, it’s not something we need to rush into and it seems to be holding up the actual fix to this. So I suggest this becomes the following:

  • the one line test @bezformy mentions: flag(this, 'ssfi', stack || Assertion)
  • no other changes
  • no additional tests

I run node globally on strict mode (via --use_strict flag)

There’s your problem! Remove that flag and things will work fine! Not every module you use will implement strict code (for example, Chai does not!). You’d be better off declaring "use strict"; at the top of every file that you want to use strict parsing.

I’m going to close this because we rely on non-strict features (which are still compliant to the JS spec, just not the “strict” part of the spec). It’s unlikely we’ll change this any time soon, and only errors through edge cases (such as enforcing strict mode on all of your modules, or using babel, etc).