-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing with Sail #26
Comments
@underthecocotree why stopping swap envs? |
From memory, I think sail caches the environment variables on load/boot. That is where ‘sail —env-file .env.cypress’ comes in handy Thinking about it I guess it wouldn’t hurt to keep it. It’s been a while since I changed any of that code. Have you been successful with testing with the code present? |
I'm a bit confused how to get this working with docker. I added the following to my ui:
image: cypress/base:latest It downloads the image but it doesn't seem to start correctly. When I run
And after running
Since I can't publish the boilerplate code, I'm unable to get the Any help would be much appreciated... |
I am leaving this here in case someone is trying to run cypress in a separate container with laravel sail. The changes below will also add novnc in a separate container that will be used to show the cypress desktop app so that you don't have to make any config changes to your system or install an X11 server. Add the following services in docker-compose.yml:
Create the following folders:
Add docker\novnc\Dockerfile:
And finally add docker\novnc\supervisord.conf:
|
@parapente not sure if I'm missing something here but when I run
|
@matthewknill first of all try to match the versions of cypress you want to use. In the above instructions I had
because I used an old project with laravel 8. Make sure to change to the one you have installed in your project with npm. Then you don't need to run If for some reason you close the cypress application, you can restart it running I haven't used cypress 10 yet but I'm really interested in its component testing feature, so if I find something not working, I will post further instructions. |
Fantastic, got it working thanks! Quite annoying to get it working with WSL2 on Windows without using a container. You can use the following to make the VNC fullscreen (set Remote Resizing): |
Worked (almost) perfectly on WSL2. Thanks @matthewknill @parapente Everything comes up in the VNC window but when running the default test I get an error Shouldn't it look for laravel.test on the internal Sail IP address? UPDATE Once corrected everything works fine :) |
Hello @matthewknill @parapente Have either of you tried to get this working with subdomains? Specifically I'd like to to test a "tenancy for laravel" https://github.com/archtechx/tenancy application but can't find a way to get cypress to connect to tenants which are subdomains, only the central domain is ok. @stancl - have you ever got cypress working? |
I've never used it unfortunately |
I'm actually looking to use this package in the future. You could get this working by just changing the |
I'm finding that |
@matthewknill you should probably run |
@matthewknill @parapente - I've got this working for @stancl Tenancy for Laravel by configuring an alias for
This means that any calls to the testing hostname from cypress or dusk are resolved to the application container using dockers internal dns magic. My complete file is:
|
Thank you @parapente . I have done the steps from you. But I got this error when execute sail up:
|
@protocyber you use a value for WWWGROUP that clashes with a group that already exists in the novnc container. Use |
I'm using mac. And by default any user is a member of Update: I have create a new group and set this as my default group But I there is another problem, the novnc cannot start:
Meanwhile there is also error in cypress container:
|
@protocyber there is a group named dialout in the novnc groups file with group id 20. Try modifying the novnc/Dockerfile by adding the following line before addgroup:
|
Thank you for responding @parapente. Unfortunately the problem still the same.
|
@protocyber Did you return WWWGROUP to 20? |
@protocyber Here are some things to check:
|
Thanks very much for your solution, @parapente! I needed to make a couple of additions:
|
You are welcome @trashbat! Indeed the alpine package for novnc is now missing websockify so your proposed solution I think is the best one you can use. |
After the latest updates to Alpine Linux packages, docker fails to build the novnc container. Updating to the latest image (3.18) novnc builds correctly. docker\novnc\Dockerfile:
|
Is there a way a way to Cypress without an VNC, and still have all the features? |
@Thinkro As Laravel Sail runs inside a Linux container you would need to use an X server for the GUI of Cypress to appear. If you are running a Linux desktop you can use xauth to allow applications from the container to appear on your screen without using vnc. If you are not on a Linux desktop, you would need an X server for Cypress to appear. It's a bit of a hassle to configure xauth and you might even end up compromising your security if you don't configure it correctly. I prefer to use novnc as it is easy to run in linux, macos and windows. |
Wanted to share a recipe to get Sail and Cypress to work nice together. We're running 2 instances of all our services, so that each time we wipe the db/meilisearch db we don't have to login/resync meilisearch etc. This way you can do https://gist.github.com/prebenvendo/6b9ae9790e4a321f5d253d3d2f016162 Let me know if anything is unclear. |
Hey @JeffreyWay,
Another great package, thanks.
I just wanted to share my journey into getting to work this with Laravel Sail. We can add this to the Readme.md, adding configurations during the scaffold might be a bit of an overkill.
Follow the
Installation
andEnvironment Handling
sections in Readme.mdEdit:
cypress/support/index.js
to stop the swapping of the .env filesRun sail using
.env.cypress
sail --env-file .env.cypress up
If you want to run tests on a separate database follow the rest of this guide.
Create a separate database
Sail does not provide sqlite, there might be a way to install it and configure it but I didn't find anything.
Credit to: https://michaelheap.com/laravel-sail-test-database/
Edit
.env.cypress
Edit
docker-compose.yml
to create a new databaseThe text was updated successfully, but these errors were encountered: