Search code examples
node-modulesruby-on-rails-6bootstrap-themes

System test fails after adding bootstrap theme via yarn


I have simple system test that was initially passing:

require 'application_system_test_case'

class UserVisitHomePageTest < ApplicationSystemTestCase
  test 'User should see home page' do
    visit root_path

    assert_css 'h1', text: 'Home'
  end
end

Then, I install material-dashboard via yarn, and added this line in app/javascript/stylesheets/application.scss

@import '~material-dashboard/assets/scss/material-dashboard';

I adjust my app/views/layouts/application.html.erb as per material-dashboard documentation.

All went working, the theme has been applied, but my system test now fails:

UserVisitHomePageTest#test_User_should_see_home_page:
ActionController::RoutingError: No route matches [GET] "/assets/css/material-dashboard.css"
  1. Why the test is searching for that route /assets/css/material-dashboard.css?
  2. How could I make it pass?

Solution

  • I was able to make the system test pass by updating my app/views/layouts/application.html.erb, removing (not including) those CSS link tags and JS script tags that reference the asset files of the material dashboard.