How to run system specs without recompiling assets every-time #136
-
@ElMassimo first off thank you for all your work, vite_ruby is amazing!! I am reaching in regards to this: First on the list is an integration test that can trigger a Hot Reload, and check the updated style or code. I'm trying to run my system specs (Capybara / RSpec) and every time the assets need to be compiled and fail the system spec with a NetTimeout. After the assets compile I can run the tests successfully. This flow is not opportune at all however, I'd really love to see hot reloading take place (maybe running bin/vite --mode=test or something along those lines so the assets don't need to go through the full recompilation process before being able to run the specs. Do you have any idea how to accomplish this? I don't see much at all in Vite or Vite Ruby (or google) that go into any depth on testing. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 18 replies
-
Edit: now possible, see this answer. I haven't tried it, but Vite.js added a Run If using Then, make sure that It should be technically possible to run tests with a Vite.js server running, but it's not advisable because you wouldn't test the behavior of the compiled JS in production. bin/vite dev
# and then override the Rails environment:
VITE_RUBY_MODE=development bin/rspec |
Beta Was this translation helpful? Give feedback.
-
Using a Vite dev server when running tests is now supported out of the box, starting from Added a test in the example Rails app that rewrites files and verifies that HMR is working. @templeman15 Run Related: Found that sourcemaps were generated when building in test mode, which is unnecessary and would really slow down the build in an app like the one you described. Running |
Beta Was this translation helpful? Give feedback.
-
I "Fixed" the Timeout error, by simply running the build once before all system specs: RSpec.configure do
config.before(:all, type: :system) do
puts "\e[31mPrecompiling assets for system specs \e[0m"
ViteRuby.instance.manifest.resolve_entries('application', type: 'js')
puts "\e[32m-> Finished! precompiling assets for system specs \e[0m"
end
end That fixes the Timeout Issues for me (Using Cuprite the Ferrum::TimeoutError, Ferrum::PendingConnectionsError errors). |
Beta Was this translation helpful? Give feedback.
Using a Vite dev server when running tests is now supported out of the box, starting from
vite_ruby@3.0.2
.Added a test in the example Rails app that rewrites files and verifies that HMR is working.
@templeman15 Run
bin/vite upgrade
, give it a try, and let me know how it goes 😃Related: Found that sourcemaps were generated when building in test mode, which is unnecessary and would really slow down the build in an app like the one you described. Running
bin/vite upgrade
should also upgrade tovite-plugin-ruby@3.0.3
which includes this fix.