question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cypress web-app in vagrant, web-browser in host

See original GitHub issue

how can we use the cypress web-app ./node_modules/.bin/cypress open --port 4567 in a web-browser on vm host?

we develop our web-shop in a headless linux virtual machine (vagrant) on a ms-windows host, and when i try to open the cypress web-app in google-chrome on host i get an error: “This browser was not launched through Cypress. Tests cannot run.”

if not possible, what is the technical limitation?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Anyokscommented, Apr 20, 2021

I figured out what to do, just in case you are still interested @hlb-schmidt or anyone else in the future: Assuming you have correctly installed cypress and can run it headless: yarn run cypress run (or whichever way you run it, npm etc)

1. You need an X-Server on the host.

  • On Linux, you already have and X Server running
  • On Mac, On Mac OSX you can install XQuartz

2. Enable X-forwarding on your Vagrant VM

Just add this to your Vagrantfile config.ssh.forward_x11 = true

3. Ssh into the box without vagrant ssh We need to access the guest with ssh as opposed to the normal vagrant ssh. Do do this: run $ vagrant ssh-config on the host in your directory with the vagrant file

$ vagrant ssh-config
Host default
  HostName 127.0.0.1
  User ubuntu
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /Users/xxxx/work/.vagrant/private_key
  IdentitiesOnly yes
  LogLevel FATAL
  ForwardX11 yes

From this we have the details we need to ssh. The user, the HostName the Port and the IdentityFile.

Now we can, from the host ssh into the guest and run the cypress test runner.

We also need to add -X flag that tells ssh to use the X-forwarding.

Assuming my project runs in a directory called project in the home directory of my guest machine… Run this command from the host machine while your box in running.

ssh vagrant@127.0.0.1 -X -p 2222 -i /Users/xxxx/work/.vagrant/private_key -t "cd /home/vagrant/project; yarn run cypress open"

Voila! the Test runner will run in your box and the GUI will display on your host machine.

Credits to Gabor and Martin

0reactions
Anyokscommented, Apr 20, 2021

hmm, Thanks for the feedback @hlb-schmidt . I do appreciate, Checking out PlayWright now. The marketing team, I believe, will eventually catch up with the right technology once they see the need to be more productive!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to run Cypress test runner in vagrant guest using host ...
1. You need an X-Server on the host. · 2. Enable X-forwarding on your Vagrant VM · 3. Ssh into the box without...
Read more >
Launching Browsers | Cypress Documentation
When you run tests in Cypress, we launch a browser for you. This enables us to: Create a clean, pristine testing environment. Access...
Read more >
How to Use MailHog to Test Emails Locally (Step-by ... - Kinsta
It's a real pain to know whether your website's or web app's outgoing emails are actually reaching the recipient's inbox. Enter, MailHog!
Read more >
How to Run Cypress Tests in Chrome and Edge | BrowserStack
This article will demonstrate how to use Cypress browser website test cases on Google Chrome and Microsoft Edge with examples.
Read more >
Example: Web Test Tools - SoftwareQATest.com
K6 - Cloud-based online load testing tool for Web app and API ... your virtual device in a web browser (no plugin needed):...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found