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
This is now live in PhoenixTest. If anyone has controller tests and is interested in trying it out that would be much appreciated!
wojtekmach
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
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!
Popular in Proposals: Ideas
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









