Skip to content

Display relevant browser console output when an RSpec test fails.

Mike Greiling requested to merge fix-rspec-console-output into master

This MR adds javascript console output back into RSpec tests, and will fail a test when any output is encountered.

Edit: This MR will produce javascript console output alongside any existing RSpec failures, but will not display console output or force failures on otherwise-passing tests (yet, see #45333 (moved)).

This can provide much needed context when tests fail due to javascript errors which were previously not represented in the RSpec output.

Care has been taken to ignore noise from the webpack-dev-server output when hot module replacement or auto-reload is enabled.

Example Output:

  1) Dashboard Issues issues shows checkmark when unassigned is selected for assignee
     Got 0 failures and 2 other errors:

     1.1) Failure/Error: expect(find('li[data-user-id="0"] a.is-active')).to be_visible
          
          Capybara::ElementNotFound:
            Unable to find visible css "li[data-user-id=\"0\"] a.is-active"
          # ./spec/features/dashboard/issues_spec.rb:32:in `block (3 levels) in <top (required)>'

     1.2) Failure/Error: raise JSConsoleError, message
          
          JSConsoleError:
            Unexpected browser console output:
            webpack-internal:///./lib/utils/url_utility.js 82:8 Uncaught Error: test javascript exception
          # ./spec/support/capybara.rb:95:in `block (2 levels) in <top (required)>'

/cc @stanhu


Mentioned here, https://gitlab.slack.com/archives/C0GQHHPGW/p1523573441000380

Edited by Mike Greiling

Merge request reports