Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 661 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get "should.be.false" syntax pass jslint?

#1
I am writing JS UT for my NodeJS code. I am using [Chai][1] as the assertion library, and I prefer the *should* syntax. I also use *jslint* to check the JS file syntax, even the JS files for UT.

Now I have a problem with *jslint* and *Chai*. In *Chai*, you can use:

myvalue.should.be.true;

But *jslint* give me:

#1 Expected an assignment or function call and instead saw an expression.

I know *jslint* comes with many options, but I just cannot find the right one to turn off this check.

[1]:

[To see links please register here]

Reply

#2
It turns our **jslint** is unable to solve my problem. And due to many restrictions of jslint, I turned to [jshint][1], and the option `expr` saved me :P

[1]:

[To see links please register here]

Reply

#3
You can also use `myvalue.should.equal(true)` instead.
Reply

#4
Just to make it clear to other readers:

You can add `/*jshint expr: true*/` to the top of the test files, so it only allows it in the test files.

In the rare case that you use that kind of expressions in your code, you can add the `expr: true` option to the jshint config options.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through