Debugging protractor tests from the console - node.js

I have a protractor test run via gulp-protractor. How can I debug this test using the command line (for example via the node debugger)?
Is there a configuration option for this?

Recently (as of Protractor 5.0.0) the recommended way to do this has become browser.enterRepl().

Starting from protractor documentation:
https://github.com/angular/protractor/blob/master/docs/debugging.md
browser.debugger() and browser.pause() should be help.

Related

testcafe execution via intelliJ run action

I have my testcafe test which is running well via terminal with
testcafe chrome jira-web-front\src\test\script\testcafe
I would like to be able to run it inside intelliJ js editor by clicking on the play button:
When I execute my test by clicking on the green play button I have:
I have some jest tests also in my project.
I tried to install intelliJ testcafe plugin but it didn't help.
Any idea about this?
Thanks
The logic currently used by JavaScript support plugin for detecting what test runner is available for a given test file is based on dependencies declarations in package.json nearest to this file: it looks for known test runners listed there and tries to run the most suitable one. As IDEA
doesn't provide any support for TestCafe (https://youtrack.jetbrains.com/issue/WEB-30315), you can't expect it to run TestCafe from a gutter; it runs your tests with jest because you have it in your dependencies list.
To run test using the run configuration provided by testcafe plugin, you need right-clicking the test in editor:
This plugin doesn't support running tests from gutter, neither it supports debugging.
Note that you can use VS Code recipes to debug TestCafe in IDEA. Namely, you need Node.js Run configuration like the following:
where JavaScript file: is set to a path to your locally installed testcafe module, e.g. node_modules\testcafe\bin\testcafe.js, and Application parameters: are testcafe cli args, like
chrome myTestFile.js

LESS #plugin Debugging (node)

Does anyone know how to debug a less plugin when using node to compile? So that I would be able to see the value of console.log() within custom less functions.
I am also using gulp-less. I have tried to run the gulp this way:
node --inspect --debug-brk /usr/local/bin/gulp compilecss
This ran the gulp task but I don't see any console from within the function inside the javascript #plugin.
The above mentioned method worked, the issue was that the plugin wasn't set up correctly. For those who were in my shoes this is what worked:
Follow the instructions on this answer for getting the inspector in the gulp task.
enter link description here
Then if your plugin is installed you should see logs in the console from the less custom plugin or it's functions.

Debugging Serverless Framework invoke local function

I am trying to debug sls invoke local.
My setup:
However I keep getting:
/Users/nikos/.nvm/versions/node/v6.9.1/bin/node --debug-brk=63417 --expose_debug_as=v8debug /Users/nikos/.nvm/versions/node/v6.9.1/bin/serverless invoke local -f createTodo
Debugger listening on [::]:63417
Process finished with exit code 130 (interrupted by signal 2: SIGINT)
OK, I've figured out how to do this with real Chrome Devtools with the excellent node --inspect. This is much better than node inspector because it uses the latest built in chrome devtools. (more info on node inspect)
node --debug-brk --inspect $(which serverless) invoke local -f myfunctionname
I ran that but my function wasn't loaded yet (probably some lazy loading in the serverless code). So I added a debugger to the top line of my function and everything seems to be working great.
In my case I also needed some test data, so I passed that through like this.
node --debug-brk --inspect $(which serverless) invoke local -f postprocess -d '{"Records":[{"eventVersion":"2.0","eventSource":"aws:s3","awsRegion":"us-east-1","eventTime":"2017-06-17T05:08:29.598Z","eventName":"ObjectCreated:Put","userIdentity":{"principalId":"ALS78N87ZDYNW"},"requestParameters":{"sourceIPAddress":"52.119.114.78"},"responseElements":{"x-amz-request-id":"2EB4FAD5892EC247","x-amz-id-2":"nVLasIYsWvWm7xwONiTB6z7L8oXKkvPOb9FntOYoG/kKS+PuWwbMJ1xM7n/C1X3NJh5FUCj4aEM="},"s3":{"s3SchemaVersion":"1.0","configurationId":"3c3b2a71-b639-4116-b246-08dcacd0c7d6","bucket":{"name":"simmer-uploads-test","ownerIdentity":{"principalId":"ALS78N87ZDYNW"},"arn":"arn:aws:s3:::simmer-uploads-test"},"object":{"key":"example+%285%29.zip","size":4757597,"eTag":"9aa90579ee4e8152e6dfa60258754a83","sequencer":"005944B94AD9307261"}}}]}'
I am working on a Mac, and I heard there might be some problems with $(which serverless) on windows. But someone give it a shot and let me know.
I was able to setup my PHPStorm debugger configuration in a way that now I can step through my functions locally (using serverless-offline plugin).
I am triggering functions via http requests using Postman.
See below steps to achieve this:
1.
2.
3.
4.
I've gotten this to work in IntelliJ, so it should work in Webstorm too. You will need the serverless-offline plugin (https://github.com/dherault/serverless-offline)
In your Run Configuration, change your Application parameters to:
offline -s dev
and add the environment variable SLS_DEBUG=*
serverless-offline will start a server that the IntelliJ Node debugger can hook into.
Use this, it emulates lambda and serverless:
https://github.com/dherault/serverless-offline#debug-process

Issue with Node-based Cordova Hook

I'm playing around with the Cordova hooks capabilities and I'm trying to test using a node application as a hook. In this article: http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/ it references running node applications, so I know it's possible.
I've created a simple node application that I'm using to test the before prepare and after prepare process:
#! /usr/bin/env node
console.log("this is a node module");
When I run my prepare, I get the following error:
C:\Users\jwargo\dev\lunchmenu>cordova prepare
The system cannot find the path specified.
Hook failed with error code 1: C:\Users\jwargo\dev\lunchmenu\hooks\before_prepare\test.js
I can't find any information anywhere about what an error code of 1 means here.
I've tested the node code and it runs fine with "node test.js" and when I execute test.js from the command line Windows simply launches my default editor.
So, can anyone tell me what I'm doing wrong or what I need to do to be able to execute a node application as a hook with the Cordova CLI?
Figured it out with some help from the Cordova dev team. The space in my shebang was causing the problem. I removed it and the problem went away.

node inspector with mocha not working with 'debugger' command

I am using mocha to test my code. I am using node inspector to debug my code.
bash
mocha test/test.* --debug-brk
This works but not so well. It stops at the first line of code in mocha. I want it to stop it at my code. I tried using the 'debugger' key word to make a manual breakpoint but some how it does not stop there.
Try placing a breakpoint at the bottom of the mocha library per this issue. For some reason that allows debugger statements in your modules to pause the node debugger.
However it doesn't seem to stop at debugger statements in the spec itself. I have a SO question highlighting that problem.
I was on the latest node version, using the node-debug command (to launch node-inspector and having the same issues you were. Here's what I'm rolling with currently:
Using the following versions:
node: 0.11.13 (I downgraded from latest) <-- I specifically had to use this one
mocha: 2.2.1 <-- might work with any
node-inspector: 0.9.2 <-- might work with any
Start your tests using the following command:
node-debug _mocha test/unit-tests.js
Navigate to your test file and start putting in breakpoints, then hit run. I usually put one up by the 'requires' of my test file, and several within my 'it' functions.
Hope that helps, and that one day this kind of thing will just work :P
Got the idea to downgrade node from here:
https://www.bountysource.com/issues/7978672-script-is-resumed-as-soon-as-node-inspector-is-loaded
And the command from here:
https://github.com/node-inspector/node-inspector#how-do-i-debug-mocha-unit-tests

Resources