Running Protractor from Node-webkit - node.js

Is is possible to run Protractor in any other way except using CLI?
Is there an API call which will simulate the command: 'protractor config file.js'?
I would like to start a test through a node-webkit application, and even though I can connect directly to the ChromeDriver through the directConnect parameter, this is no use if I can't run protractor from inside the script.
Of course, this is in an environment where Node and Protractor aren't available from CLI... simulating a distribution environment where the user doesn't have to install additional apps apart from my node-webkit (hence the node-webkit usage).
Thank you in advance for any pointers!

The protractor command line script boils down to invoking lib/cli.js which mostly deals with parsing commmand-line arguments and then invokes lib/launcher.js to actually start protractor.
I don't think any special concessions have been made in these files to be directly invoked programmatically, but I don't see any particular hurdles either.

Related

WebStorm remote interpreter not working with TSLint

I followed this link to setup a remote interpreter with Docker in WebStorm, now I would like to use it as the interpreter for the TSLint plugin, I get this in the upper window:
But when I try to configure the interpreter I only get the option for a local interpreter.
Is there any way to configure it to use the remote one?
This is what I see:
Not possible ATM. Here is official explanation: https://youtrack.jetbrains.com/issue/WEB-25411#comment=27-1906237
This is the correct behavior described in Help (https://www.jetbrains.com/help/webstorm/2016.3/node-js.html)
The reason is that the project Node.js interpreter is used in many places - to run TypeScript service/compiler, external linters, etc. And all these services require local Node.js interpreter, they can't be run remotely. The only place where remote interpreters are supported is Node.js running/debugging. That's why setting up remote interpreter is only possible from Node.js Run configuration
There are requests to add support for remote execution for Karma/Mocha/ESLint -- see those tickets -- maybe you will find and answer there (or create new Feature Request ticket if these tickets below do not have clear answer/not suitable for your needs):
https://youtrack.jetbrains.com/issue/WEB-20824
https://youtrack.jetbrains.com/issue/WEB-14665
https://youtrack.jetbrains.com/issue/WEB-22179
On related note (this comment and around):
https://youtrack.jetbrains.com/issue/WEB-22572#comment=27-1836383
If so...our Docker integration isn't currently for that use case. Everything to do with the development – linters, build tools, test runners, ts language service, angular language service, angular cli, react project generator, react native, etc. – runs against a local NodeJS and node_modules.

Run jest with electron instead of node

To make a long story short, I'd like to run my jest tests (using CLI) with electron instead of node.
It's relevant when using native module, because you need to build them using electron header while jest run them using plain node.
So I must either build my native modules for my app (at least in dev mode) or my tests, I can't have both to work.
In this thread they propose to use mocha, but I want to use jest, which is far more advanced and interact well with React.
Note that I don't want to mock the native module, since I write integration tests.
I opened an issue about the zmq github repo. One proposed solution is "to target your tests using ELECTRON_RUN_AS_NODE=true electron as your node runtime".
This is a very good solution, since using electron will both make the test environment closer to the execution environment and solve my specific issue with native modules.
I'd like to apply that, but I do no seem to be able to setup the jest CLI to use electron instead of node, and I have no idea where to start. Maybe I should run jest programmatically without the CLI ? But I might lose the nice test filtering features of the CLI.
Has anyone solved this already?
"ELECTRON_RUN_AS_NODE=true ./node_modules/.bin/electron ./node_modules/.bin/jest works fine
If you're on Windows, then Eric Burel's excellent discovery might need a bit of a tweak to use the environment variable, and call the right version of Jest:
cross-env ELECTRON_RUN_AS_NODE=true ./node_modules/.bin/electron ./node_modules/jest-cli/bin/jest.js
Sadly, the colouring of the text in the results is lost.

Cannot find module 'nw.gui' - node webkit updater

I'm trying to use node webkit updater for my aplication,but when i'm trying to test is(using npm test) or start it(using nmp start) i'm receiving this error .Both commands are used from Nodejs command prompt .
The js file used is updaterClientABC.js and the error comes from this line: var gui = require('nw.gui');
This is my folder structure :
Can you please tell me what should i do ? I admit that i am a beginner i've never worked with node-webkit.Some advices will be very helpful :)
I noticed this thread:
node module 'nw.gui' not found
So yes, this kind of thing is due to how NW.js gets called (directly or from within a project). I've run into this problem as well. In this case, in the above, you call updaterClientABS.js directly from node.js. To run a node-webkit project you need to load it via the NW.js binary, which in turn requires node.js.
It's also possible, as was my problem with this, that I was trying to access the nw.gui within the Node context (vs browser context). My solution was to access it via the browser context (which has more global access, not just Node.js objects).

How to test NodeJs CLI javascript

I need to put some tests around a nodejs command line utilities\modules. No browser involved and I'm using a lot of the "fs" module to work the file system, so i'm not sure a browser based test mechanism would work (sandboxing).
any modules that would help here?
Check out Vorpal.js. This lets you create an interactive CLI in node, in which you can then run custom commands to test the various things you want to test.
Disclaimer: I am its author.

Start app on mac os directly after installation

I'd like to know if it is possible to create a dmg file which can be installed by Drag&Drop - and which starts directly after this installation without having to be called manually again.
And if this is possible, I'd like to know whether I can pass arguments to the (nodejs) process which will be started directly after the installation.
I managed to pass parameters to the process when I call it manually after the installation, but I want to run it directly.
Any help will be appreciated!
Thanks!
I solved it: Instead of creating an app and wrapping it into a dmg, I created an app and wrapped it into a pkg. For pkgs it is possible to use postinstall scripts, so I started the application through this script.

Resources