sentry-elixir icon indicating copy to clipboard operation
sentry-elixir copied to clipboard

Add full e2e phoenix app test

Open solnic opened this issue 1 year ago • 5 comments

Here's a test setup that does e2e testing with a real phoenix app. This will be handy when testing more complex integrations like OTel stuff for a good start. It should also help us reduce the risk of introducing regressions in Phoenix apps (once we add more tests of course).

The only custom "trick" I had to use was defining endpoint in test/support because I made sentry depend on the phoenix_app from test/fixtures/phoenix_app and the endpoint needs access to Sentry.CapturePlug.

Another nice benefit is that we could set it up in the Sentry SDK project and it would make it simpler to test things out w/o having to create new setups manually.

solnic avatar Sep 17 '24 10:09 solnic

I’m wondering if a better way to do this would be to instead have a Phoenix app in integration_tests or something, and then have a specific Mix task for testing that app (mix test in the app basically). That app can then depend on {:sentry, path: ".."}.

https://github.com/elixir-ecto/ecto_sql does all this setup and has been running it successfully for a while, so it could be a good source of inspiration.

whatyouhide avatar Sep 17 '24 15:09 whatyouhide

@whatyouhide yeah this makes sense, thanks for suggestion!

solnic avatar Sep 18 '24 06:09 solnic

==> Running tests for integration: phoenix_app ** (Mix) You're trying to run :phoenix_app on Elixir v1.13.4 but it has declared in its mix.exs file it supports only Elixir ~> 1.14 Integration tests for phoenix_app failed Error: Process completed with exit code 1.

So, what's our strategy here? Can we drop 1.13 support given that more recent Phoenix versions do not support it?

solnic avatar Sep 19 '24 08:09 solnic

I made mix test skip running test.integrations when Elixir version is < 1.16 for the time being.

solnic avatar Sep 27 '24 09:09 solnic

@whatyouhide thank you so much for all the suggestions! I applied all of it + rebased/squashed + updated #784 (which waits for reviews too šŸ™šŸ»)

solnic avatar Oct 14 '24 10:10 solnic