pat / combustion

Simple, elegant testing for Rails Engines
MIT License
707 stars 51 forks source link

Support for webpacker + capybara ? #116

Closed DiegoOrejuela closed 3 years ago

DiegoOrejuela commented 3 years ago

Hi guys. I'm having trouble testing a rails engine with webpacker + capybara + rspec. Will there be any guide on how to achieve this?

Thank you

pat commented 3 years ago

Hi Diego - I've not used Webpacker and Combustion together before, but it'd certainly be great to get it working! Are you seeing any errors? Or otherwise, what's not working?

DiegoOrejuela commented 3 years ago

I understand. The truth I have come to this gem looking for a solution to the integration of gems that I said in my first comment. For some reason when I use capybara it is not looking for compiled webpacker packages in the engine. So I wanted to know if this was addressed by this gem or if anyone had addressed this. The truth is that it is a bit difficult to find documentation on Rails Engines configurations.

pat commented 3 years ago

I don't suppose the source for this engine is public? Or are you able to recreate the issue in a test engine so that I can try to get it working on my machine too? (I'm just not very familiar with Webpacker)

DiegoOrejuela commented 3 years ago

Yes, only need a little of time 😅

DiegoOrejuela commented 3 years ago

Hi @pat

Thanks for waiting

I have made the repository engine_with_webpacker to reproduce the error that I tell you. You can find in the Readme a description of the problem and screenshots, the requirements you need to install the application and the steps to follow.

There are some configurations that maybe are too many because I have used a template that I have because installing webpacker in an engine is very tedious and other configs, but they should not affect the correct operation at all.

Thank you, and I am very attentive to what you find.

pat commented 3 years ago

Hi Diego - thanks for putting together that test repo, greatly appreciated.

I've had a bit of a look - and initially, I was using the dummy app's rails server without either of the webpack-dev-server processes running. In this case: the development environment is like the test environment, where the engine's assets don't work. When I switched to using both app and engine webpack-dev-servers, it did indeed work in the development environment. I remain unsure about how to fix this though!

The fact that Webpacker v6 is due soon and seems to have some different behaviour/configuration compared to v5 makes me cautious about trying to debug this. Maybe it's worth waiting for v6 and hoping that engine support is better? And I wonder if engines should have compiled assets rather than dynamic, so a webpack-dev-server isn't required for the engine when running within an app? And so, compiling should be run as part of the test suite?

DiegoOrejuela commented 3 years ago

Hi @pat . Apology for the wait.

Maybe for version 6 it has better support, but actually I doubt it, because for the current one it was a long process.

I also posted the bug on Capybara and was able to find the solution. I leave you here the link.

https://github.com/teamcapybara/capybara/issues/2455

Thanks for your time and efforts.