[Bug]: Browser testing doesn't work for domain based routing
What Happened
Hi,
I installed PestPHP 4 for its browser testing but my project uses domain based routing.
I can completely see how this presents an issue and why this is problematic, I considered overriding the domain to the temporary server URL but I don't know it until its happened as the port is dynamic.
Is there a workaround for this?
How to Reproduce
Pull down the test project and run the tests
Sample Repository
https://github.com/chrispage1/pest4-testing
Pest Version
4.0.0
PHP Version
8.4.11
Operation System
macOS
Notes
No response
currently having fun at laravel live dk, can you try to come up with a pull request for that? check the laravel http server class, and see if you can "by pass" that check.
currently having fun at laravel live dk, can you try to come up with a pull request for that? check the laravel http server class, and see if you can "by pass" that check.
Will do Nuno 🫡 Hope you're enjoying Laravel Live!
Hey @nunomaduro - I've raised a PR in the Laravel project as this seems like a logical place to do it!
I found this issue after creating a PR in the browser plugin which overrides the host header as @nunomaduro mentioned before. I don't want to boast my PR here but thought it could help in deciding what approach would suit this issue best.
I found this issue after creating a PR in the browser plugin which overrides the host header as @nunomaduro mentioned before. I don't want to boast my PR here but thought it could help in deciding what approach would suit this issue best.
Ah I do like you're implementation here! It does make sense that it's perhaps better to specify the hostname rather than ignore altogether as that is then another level of testing.
We also have domain based routing (several domains) in a monorepo. In our existing playwright tests we had fixtures for each domain that would set things like the base url for all requests.
It was added https://github.com/pestphp/pest-plugin-browser/commit/d917f1b30107e3608833d18794749dd6995f0d9d and removed again https://github.com/pestphp/pest-plugin-browser/commit/45e762f14cc20072d85c83cc2513cbeac6fe6584. What is the current state of supporting multi domain projects @nunomaduro ?
We also have domain based routing (several domains) in a monorepo. In our existing playwright tests we had fixtures for each domain that would set things like the base url for all requests.
Do you reckon there is a way to do this with Pest 4, even as a workaround? I imagine navigating between different subdomains would not work? Could you give us an idea of what those fixtures looked like?
I don't think there is a workaround at the moment. The way this plugin is structured means you don't have access to the Symfony request that gets passed to the HTTP server they boot up. And you need that to set a Host header.
My PR did all that, but it got removed later without any feedback, which is a shame, but it is what it is.
We also have domain based routing (several domains) in a monorepo. In our existing playwright tests we had fixtures for each domain that would set things like the base url for all requests.
Can you please share or give an idea how to set up fixtures like these?