Cypress 10 - Open command - Run spec automatically - cypress

When I start cypress 10 with the open command I need to run a spec automatically. Can it be done? How?
The run command does have an option to set the spec files to run (cypress run --spec ), but I need to do this when starting the Cypress application with the open command (I tried the --spec option but it didn't work).

Related

Cypress --headless still opening browser window on mac os

npx npm run cypress --headless running this code in my project is still opening up a google chrome user, requiring UI to keep it going
no matter what I try, even uninstalling and reinstalling cypress doesn't fix the issue
The correct way is:
cypress run
Actually by default this command is executed in headless mode, that's why it's not necessary to write --headless. And if you want to run it in headed mode, then:
cypress run --headed

how to run appium command on startup by using terminal

I want to run appium program and see appium process running in terminal automatically on startup
I have created a simple bash script to run the appium command using gnome-terminal.
appium.sh
#!/bin/sh
gnome-terminal -- appium
and when I run the command by terminal ./appium.sh it works.
(Use `node --trace-deprecation ...` to show where the warning was created)
[Appium] Welcome to Appium v1.21.0
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
but when I put in sudo nano /etc/xdg/lxsession/LXDE-pi/autostart to run the program automatically at startup.
#lxpanel --profile LXDE-pi
#pcmanfm --desktop --profile LXDE-pi
#lxterminal -e bash /home/pi/appium.sh
#xscreensaver -no-splash
gnome-terminal opens successfully, but the appium command fails to run.
There was an error creating the child process for this terminal
Failed to execute child process “appium” (No such file or directory)
Is there something wrong ? please help

How can I tell Cypress to hide Chrome when running from the command line?

Problem
I want to be able to run my tests in terminal, but all my tests fail due to Cypress using Electron as the default browser and I want it to utilize Chrome, but without having to specify it in the command line.
Current Outcome
I know I can use the command npx cypress run --browser chrome to tell Cypress to use Chrome instead. However, it opens the browser AND runs it in command line.
Expected Outcome
Ideally it would only require me to run npx cypress run and this would only run in the command line using Chrome.
Summary
Is there a way to set the default browser to Chrome instead of Electron so I wouldn't need to specify which browser to use?
Is there something to add to the package.json file to set the default browser to Chrome or a line to inject somewhere? I checked the docs and I couldn't really find anything other than the --browser command.
** Cypress Github Open Issue **
Here is the link to the open issue on their github regarding a headless chrome and also to change the default for cypress run
Support chrome headless and change defaults for cypress run
Photo for the debugger
Sorry for the terrible scribbles...I am under an NDA so had to go back and scratch out all the path names for my project as well as my last name.
Cypress 3.8.1+ allows you to pass --headless to cypress run to make Chrome invisible on any operating system by using Chrome headless:
cypress run --headless --browser chrome
Outdated answer below:
There is not currently a way to hide Chrome in run mode on macOS or
Windows.
We'd like to support it, but we'd have to find some kind of workaround
for xvfb not being available. We can't use google-chrome
--headless either because it won't allow us to install the Cypress extension.
The advice below will only work for Linux.
npx cypress run --browser chrome is the correct way to do what
you're trying to do.
If you are on Linux, you can make it run Chrome in a virtual
framebuffer (so it will be hidden from you) by blanking out the
DISPLAY env variable:
DISPLAY= npx cypress run --browser chrome
Technical explanation:
Cypress does not support running in "headless Chrome" - headless Chrome was not around when Cypress was first written
So, when Cypress is running in Chrome in CI, it uses xvfb to create an X virtual framebuffer, then it uses the DISPLAY variable
to tell Chrome to run in the xvfb
However, if you have DISPLAY set (by default, it is set on Linux if you have a display manager), it will use that DISPLAY instead -
this is why it appears even though you're doing cypress run.
Adding DISPLAY= before the command nulls out DISPLAY, which means that Cypress will spawn xvfb and run it inside of there
instead.

On Windows, how can I stop npm from running processes in new windows?

When I run npm commands on my Windows 10 machine, new processes seem to spawn in new windows.
On my (Mac-using) colleagues machines, I see that these commands run in the same terminal window from which they were called. This is the behaviour I'd expect and is much more useful - it's really hard, for instance, to see my test results in the split second between them finishing and the terminal window being closed!
As an example, our packages.json has a script to run jest:
scripts": {
"test": "jest"
}
When I run npm run test, the following gets written to the current terminal:
$ npm run test
> #headuplabs/mobile#0.0.1 test C:\Users\TomWright\Documents\Repos\HeadUp.Mobile
> jest
But the actual execution of jest then gets started in a newly created window:
I'm using "git bash" as my default integrated terminal in VS Code, but I'm able to replicate this using cmd.exe and outside VS Code (i.e. by running git bash or cmd standalone).
I presume that my npm installation is improperly configured, but my Google search haven't yielded any answers.
Does anyone know what I'd need to do to make npm processes run in the same terminal window?
As mentioned in "how to set shell for npm run-scripts in windows", you might want configure the shell in npm itself:
npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"
That would avoid the default setting, which can trigger a new shell window.

Unable to install qunit using npm

I was trying to install "qunit" using Windows command Prompt by executing the command
"npm i qunit".
On executing , it loads something and then it does not show anything . I have to press Ctrl+C twice to stop whatever this command is executing in the background.
Because of this "qunit" is not getting installed properly.
How should i resolve this problem ?

Resources