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, 2020 in Node-js by kartik
• 37,520 points
702 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, 2020 by Niroj
• 82,840 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, 2020 in Node-js by Niroj
• 82,840 points
9,522 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, 2020 in Node-js by Niroj
• 82,840 points
7,249 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 17, 2020 in Node-js by Niroj
• 82,840 points
822 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, 2020 in Node-js by Niroj
• 82,840 points
6,109 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, 2020 in Laravel by Niroj
• 82,840 points
23,023 views
0 votes
1 answer

What is redirection in Laravel?

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

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
3,000 views
0 votes
1 answer

How to install Laravel via composer?

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

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
2,922 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, 2020 in Laravel by Niroj
• 82,840 points
44,768 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, 2020 in Node-js by Niroj
• 82,840 points
3,261 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, 2020 in Node-js by Niroj
• 82,840 points
2,832 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP