See the Browser’s Console Messages in Rspec

In your rails_helper.rb file, in the Rspec.configure block (of course), add this little magic:

  config.after(:each) do |example|
    if self.class.metadata[:type] == :feature
      puts "BROWSER LOGS -------------> \n " +  page.driver.browser.logs.get(:browser).join("\n") + "\n<------ END OF BROWSER LOGS"

Now anything you print out to the frontend with ‘console.log’ will automatically get piped right to your Rspec output for all your feature specs.