testcafe execution via intelliJ run action - node.js

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

Related

ChromeNotInstalledError while using chrome-launcher npm package

I am using chrome-launcher for running lighthouse programmatically. It works fine locally but when I run it on azure I am getting an error.
On this statement const chrome = await chromeLauncher.launch({chromeFlags: ['--headless']}); I am getting the following error:
ChromeNotInstalledErrorat new LauncherError (C:\home\site\wwwroot\node_modules\chrome-launcher\dist\utils.js:37:22)at new ChromeNotInstalledError (C:\home\site\wwwroot\node_modules\chrome-launcher\dist\utils.js:68:9){message: 'No Chrome installations found.',code: 'ERR_LAUNCHER_NOT_INSTALLED'}
How can I solve this?
You need to install Chrome on the Azure Function app somehow.
One way to do this is by using an npm dependency that installs Chrome as part of its install process. Examples of this are puppeteer and playwright. Although then you end up with some unnecessary dependencies.
You could also have a startup script or something that installs Chrome before running chrome-launcher/lighthouse. You'll need to tell crome-launcher where Chrome is installed if it's not a standard place using chromePath options or CHROME_PATH environment variable link.
You also have to ensure you do a Remote Build for the Function app.
You will also run into this error, which has a possible workaround: https://github.com/GoogleChrome/chrome-launcher/issues/188
Overall it's not easy. I actually ended up moving my workflow to GitHub Actions instead as Chrome is already installed on their runner images.
See:
https://anthonychu.ca/post/azure-functions-headless-chromium-puppeteer-playwright/

Vue JS Intellij setup

I am working on a Vue js application but am having difficulty getting it to run/debug within IntelliJ. I am currently running it from the command line but I'm interested in getting it to debug in IntelliJ. Not many tutorials out here on getting this set up to work. Is there anyone that has experience in setting up this framework and IDE?
Steps are rather straightforward and described in blogpost:
First, install the JetBrains IDE Support Chrome extension. This will bind the browser debugger environment with IntelliJ in real-time.
start the server with npm serve (can be done from a gutter in package.json):
create a new JavaScript debug configuration, specify the URL your app is running on (usually http://localhost:8080) in it, put the breakpoints right in the source code, and start the debug session.
See also https://blog.jetbrains.com/webstorm/2019/03/get-started-building-apps-with-vue-js-in-webstorm/ for some hints on working with Vue.js in IDEA. And https://medium.com/dailyjs/stop-painful-javascript-debug-and-embrace-intellij-with-source-map-6fe68eda8555
You can add "Run Configuration" for any project to run in Intellij. For this, you must have a run script in package.json.
Refer below link for a screenshot. NPM Run Configuration Sample:
Choose NPM and give like this. Once done, you are all ready for clicking the RUN button available in the toolbar to run the project

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

Debugging node app in WebStorm when run from gulp

I am using webstorm 10.0.2 and have used the bangular yeoman template to generate a project. I can run the gulp commands via the gulp window, and I can set a breakpoint in the gulpfile.js and it will hit it, but I can't seem to get it to hit a breakpoint in my server.js
It looks to me like the gulp file is launching another instance of node and thus when you do "debug" from webstorm you are just debugging the gulp.
I also tried with another project using yo hottowel but get the same thing - I am unable to debug the actual application through webstorm.
Can anybody tell me how to configure webstorm so that I can debug the actual server side node code but still use the gulp build tool?
I contacted JetBrains support back in May 2015 and their response was:
It seems this cannot be done quickly. In short, the problem is that serve-dev task starts new process (nodemon) that takes app.js
There is no workaround how to debug such spawned processes right now. We would really appreciate if you'll submit a feature request about it in our YouTrack: https://youtrack.jetbrains.com/issues/WEB
The only way you can try to avoid it - try to create a separate task that will run app.js directly without nodemon process and debug this task instead.
It seems the best option is to use https://www.npmjs.com/package/gulp-node-inspector

Resources