How to get “should.be.false” syntax pass jslint?

0 votes

I am writing JS UT for my NodeJS code. I am using Chai 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.

Oct 16 in Node-js by kartik
• 35,720 points
85 views

1 answer to this question.

0 votes

Hello @kartik,

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.

Hope it helps!!

Thank you!!

answered Oct 16 by Niroj
• 77,920 points

Related Questions In Node-js

0 votes
1 answer

How to write a test which expects an Error to be thrown in Jasmine?

Hello @kartik, Try using an anonymous function instead: expect( ...READ MORE

answered Jul 13 in Node-js by Niroj
• 77,920 points
79 views
0 votes
1 answer

How to Get data from fs.readFile?

Hello @kartik, The function you have defined is ...READ MORE

answered Jul 15 in Node-js by Niroj
• 77,920 points
354 views
0 votes
1 answer

How to get the server's port?

Hello @kartik, I use this way Express 4: app.listen(1337, ...READ MORE

answered Jul 16 in Node-js by Niroj
• 77,920 points
37 views
0 votes
1 answer

How to get access to webpack-dev-server from devices in local network?

Hello @kartik, You can set your ip address ...READ MORE

answered Jul 17 in Node-js by Niroj
• 77,920 points
655 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18 in Laravel by Niroj
• 77,920 points
3,498 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18 in Laravel by Niroj
• 77,920 points
418 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23 in Laravel by Niroj
• 77,920 points
287 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23 in Laravel by Niroj
• 77,920 points
4,195 views
0 votes
1 answer

How to get GET (query string) variables in Express.js on Node.js?

Hello @kartik, Since you've mentioned Express.js in your ...READ MORE

answered Jul 8 in Node-js by Niroj
• 77,920 points
413 views
0 votes
1 answer

How do I get the path to the current script with Node.js?

Hello @kartik, you can do this: fs.readFile(path.resolve(__dirname, 'settings.json'), 'UTF-8', ...READ MORE

answered Jul 8 in Node-js by Niroj
• 77,920 points
544 views