sodapopcan

sodapopcan

Suggestion/Discussion: Bring `open_browser` to controller tests

This past weekend I’ve been doing some work on a PR to bring open_browser to PhoenixTest. For those who don’t know it, PhoenixTest is a new library by @germsvel (introduced here) which provides a DSL that works for both LiveView tests and controller tests. It’s a great lib and I find its terse DSL to be the real value prop over the unification aspect, though that part is definitely very useful as well.

In any event, I’ve been able to get open_browser to work with controller tests. Of course, my PR still hasn’t been tested by anyone other than me so that combined with the fact this isn’t already in Phoenix has me thinking that maybe I’m missing something key. Admittedly, this post is also putting out some feelers to the core team about this.

Otherwise, could this be brought to Phoenix?

I do see how it would be a bit of a task to bring it over. Some code from LiveView would have to ported over to Phoenix then made available back to LiveView. The open_browser function itself would need a place to live. To me the most obvious place is Phoenix.ConnCase except that that will cause problems when importing LiveViewTest. Both are needed for LiveView tests so there would be a conflict open_browser function. The main problem here is explaining to users that they will have to use except: [open_browser: 1] so I don’t see that as a viable option. Of course, it could be moved to Phoenix.ConnCase and it could just know about LiveViews, but that’s likely also not ideal.

Anyway, that was a lot of speculation so I will I’ll just end this here.

What do you all think? How big a demand is there even for this feature? Perhaps it’s just something that should just live in PhoenixTest (if my PR gets through)?

Most Liked

sodapopcan

sodapopcan

This is now live in PhoenixTest. If anyone has controller tests and is interested in trying it out that would be much appreciated!

wojtekmach

wojtekmach

Hex Core Team

This is an awesome idea. I wouldn’t sweat it about porting it to Phoenix just yet. I’m glad to see there’s appetite to add this feature to PhoenixTest so I’d focus on that so people can start using it and providing feedback. I’m sure the Phoenix team will figure out the best to integrate it, especially when it has been proven in a third party library by that time.

germsvel

germsvel

Love that people are using the library! And @sodapopcan is being modest. This open_browser was all his doing. And I love that it works with non-LiveView pages. It’s sooo cool to have a feature that isn’t available any other way!

Where Next?

Popular in Proposals: Ideas Top

tubedude
Hey, Earlier i posted a question, but after some research I think a proposal is due. Working on a Phoenix Live View app, I needed clien...
New
sezaru
When writing my code, I always find __MODULE__ very useful to use as alias of that module “inner dependencies”, ex: alias __MODULE__.{Im...
New
azyzz228
The slow network is known to be an Achilles heel of LiveView’s architecture. Recently, I was working on creating a fast rendering map wi...
New
Rubas
Current Challenge When testing LiveViews that use assign_async, we can’t really operate on the async data. render_async(view) waits f...
New
engineeringdept
In 2026 double submit/session tokens are no longer necessary to prevent against CSRF attacks. Instead, we can use the Sec-Fetch-Site head...
New
mikesax
On a Rails/Turbo site, the first page is typically loaded using http GET and then sockets are used navigate and replace HTML content for ...
New
calebjosue
I am reading (Once more) the Phoenix web framework documentation, in the From endpoint to views section contained in the Request life-cyc...
New
davydog187
I’ve been enjoying the new Streams API, but I keep needing to work around the lack of access to the underlying items. One issue that cons...
New
7rans
I implemented Access behavior for a struct today. Pseudo-code… defmodule MyStruct do defstruct data: %{} @behaviour Access # ... ...
New
sevensidedmarble
I have a very simple suggestion: the generated config/dev.exs file should read from PORT at compile time to set the endpoints port. If ...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53690 245
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47930 226
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement