Console.log is not working in Qunit tests with grunt server - javascript

I am creating Qunit tests which are running on grunt server. In the test when I am trying to use "console.log" to log some output to the console, it is not printing anything in the console.
Currently I am able to use only OK to perform the assertions.
Please give your inputs.

If you are using the qunit task in grunt, you need to start the task with --debug (i.e. grunt test --debug). You will then see phantom logs printing out your console logs in the following format:
[D] ["phantomjs","console","MIXPANEL PEOPLE REQUEST (QUEUED, PENDING
IDENTIFY):"]
See documentation

Related

is there a way to get the same type hardhat test output when running a script on a hardhat forked node?

I'm new to hardhat and mocha, I'm testing a flashswap contract and would love to see the same output as when I run a mocha test
I can obviously read and print the transaction receipt when I run a standalone script but obviously not as helpful as the stack call that the hardhat tester gives. Is there a way I'm missing to catch the hardhat network exceptions?

Understanding how http requests work on Mocha

I understand that mocha uses superagent under the hood, but how does it work when I haven't started a local server? Does mocha start a server by itself and send http requests to it or am I misunderstanding how mocha works in the first place?
For clarity, I checked and currently I do not have a local server running and that's when I got a bit confused as to how mocha tests work under the hood
Mocha runs JavaScript code with Node, just like your npm scripts which runs your local server. You just don't see it on the console like you do when you enter npm run debug or whatever your script is. So under the hood it's just Node running the JavaScript.
Which is why you don't need to start a server because it's already running while tests are executing. You just aren't seeing the console logs you're use to, except for what Mocha prints of course. See their page for more details.

where to find console in Node-RED

I can't find the console for Node-RED.
Do I have to use Node-RED Runtime API's RED.log()? Some Node-RED frontends, like FRED, seem to have a console. Also here a console is mentioned.
Is there a console accessible on the shell, or do I have to use the debug-Node?
Thanks in advance
Peter
Node-RED outputs data to the terminal it is started on.
So if you start it manually on the command line with node-red or node red it will print to the terminal.
If you've installed Node-RED as a service so it is launched at startup then it will depend on what platform you are on as to where the console log will end up. On Linux then there is a fair chance that it will end up in the journal and can be tailed with the following command:
sudo journalctl -f -u nodered -o cat
If you're running Node-RED on Bluemix then the you can see the console with the cf command line too:
cf logs <app-name>
or you can see it in the Bluemix web console.
As for sending data to this output then you have a few of options.
The Debug node has an option to output to the console, this is useful when the msg object (or msg.payload) is too big to fit in the debug side bar.
When writing your own nodes then you can use RED.log, This will add a time stamp and a node id to the output which can be useful when debugging.
At a pinch you can use console.log, but this will just dump things to standard out with no formatting or time stamp

When does iisnode create stdout log files?

I'm deploying my first node app and running into some issues. I am using iisnode and can see that it writes stdout log files which contain useful console logs from my app. What triggers these log files to be written? Just trying to get a handle on how they are born in an attempt to can get a handle on what's going on!

Is there some way to cause VS Build to fail on JS Hint errors using the WebEssentials plugin?

I have my app throwing JSHint violations into the Error Output using "LintResultLocation": "Error" but the build still "succeeds" and doesn't give any indication that something is wrong unless you specifically go look at the Error Log. I would like to cause a build Error that will be caught by our TeamCity build server. Is there a way to do this??
Teamcity automatically fails a build if a process is exited with some error code. However if your process in not returning error code you can alternatively fail the build based on a search string in the logs. You can set a Build Failure Condition which will search for a specific text in the logs and fail the build if the text is found.

Categories