Configuring Cypress's Electron browser to handle downloads - node.js

Is there a way to configure the Electron browser that is within Cypress, by directly modifying the Electron browser's configuration?
Namely, there's an issue with Cypress where it cannot detect download prompts. However, there's a solution that could hypothetically be applied to Electron, which would fix this issue with Cypress.
My thought was to go directly to wherever Electron is being run from within the Cypress library after installing it via npm. However, I cannot find anything pertaining to Electron in my node_modules/, even though Cypress's GitHub repository has mentions of Electron in its code.

I had the same issue and I know your questions is quiet a bit old but anyway - a solution is in development directly at Cypress:
https://github.com/cypress-io/cypress/issues/949#issuecomment-755975882
Update: It is available in Cypress >=6.3.0: https://github.com/cypress-io/cypress/issues/949#issuecomment-763323357

Related

Convert existing Angular project to Universal, encounter 'referenceerror: navigator is not defined'

I recently faced the task of converting a fairly mature angular project to SSR because I had overestimated the search power of SEO in angular projects. I'm not familiar with node, my angular project is on an apache server and uses php(slim) as the backend api, however, when I started trying to use "most of the tutorials", i.e., the first step, introducing nguniversal/express-engine into the project, it went well, npm did not report any errors.
Then I tried to run npm run build:ssr and it also worked fine. The problem is that when I run npm run serve:ssr, it ends up throwing a "ReferenceError: navigator is not defined" error...
Earlier, I built a completely clean angular project for testing, from build:ssr to run serve:ssr. Even I specified node xxxx/xxxx/main.js directly, no problem, which is obvious, because the angular project for testing is absolutely clean.
However, this does not work on my current "existing angular project". Yes, I fully understand that SSR doesn't allow for navigator or most so-called DOM manipulation, and although I'm not familiar with angular universal yet, I've previewed it and I know that's not possible, but here's the biggest problem :
In this existing angular project, there is no any navigator operations, not even a single line of code
In fact, main.js is also generated automatically, I can't stop it at all, I don't understand why there is "navigator" written in main.js?
I've checked many so-called solutions, including writing something in server.ts, but nothing helps, how can I continue? This is really quite desperate!
Big thank any help!

Can't run a custom fork of electron-builder

I'm using electron-builder (20.44.4) for installer/updater functionality in my electron application.
There is a problem with it that it does not allow to customize the folder where updates are saved - it has just an method which does not support any customizations.
In order to resolve the issue i tried to fork the library, make a small fix inside and reuse it as a fork. For that i added this line to my package.json:
"electron-builder": "https://github.com/MY_ORGANIZATION/electron-builder/tarball/COMMIT_HASH",
Unfortunatelly, i was not able to build the app using the forked version - it gives me an error ("electron-builder is not recognized").
I also tried to make some kind of "monkey patching" (i really need quick & dirty solution for this), but i can not find a way to do such trick in node - is it even possible?

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.

Headless browser automation app via electron js app

I would like to create an electron app that can do some web automation based on user input into a GUI. In my research it seems my two best bets are Phantom and Selenium+Chromedriver.
The thing I'd like to do is have an app that someone else could download and run without any additional setup. It seems with Chromedriver and Phantom that I'd need to have others download and add these things to their PATH. In order to get things functioning.
Is there a way around this? Or is there another approach I should be taking? Any advice is appreciated. Thanks!
First off, you should have a look at Nightmare.js which is like PhantomJS in many ways, but uses Electron under the hood (and that's good, because Chromium in Electron is very fresh compared to PhantomJS engine).
If you still want to use PhantomJS in Electron that's quite fine too. You may bundle it with your application or install npm module as a dependency and require that in your script. The main thing is - PhantomJS will be installed together with your app and you know the path to that folder.

AngularJS app have different behavior locally and on Heroku

I have written an app using the MEAN-stack(MongoDB, Express, AngularJS Node.js). Locally everything works as its supposed to but for some reason it behaves differently when I run it on Heroku.
The problem is that some of my angular controllers are transferred with the content type header text/html instead of application/javascript. As stated this is not a problem locally.
I have updated my npm and bower packages so everything should be up to date. Except for express where I use v. 3.4.4(because version 4.x.x requires a rewrite of the config). I use the same version of the frame works locally and on heroku.
Please let me know if I can provide any more information that would make it easier to solve the problem.
Regards
In most of the cases, when your scripts are transferred as text/html, it's because they are not found and return an HTML 404 page, you can check it using the Chrome Developer Tools in the Network tab.
When you have this issue, there is a lot of chance that your app is completely broken and that's why I ask you this.
Don't know if you're using some tasks runner like Grunt for your deployment process or just pushing your project as is but in both cases you need to check that the path of your files are correctly set by checking the requested url of yours scripts transferred with the wrong MIME TYPE.
Had also same problem with the Yeoman generator that was messing with the minification and file renaming some time ago.

Resources