feat(system-spec): display js console error

This commit is contained in:
simon lehericey 2022-10-24 21:10:22 +02:00
parent 1e88d1a1d7
commit 5d38345478
4 changed files with 14 additions and 0 deletions

View file

@ -100,6 +100,7 @@ group :test do
gem 'launchy'
gem 'rails-controller-testing'
gem 'rspec_junit_formatter'
gem 'selenium-devtools'
gem 'selenium-webdriver'
gem 'shoulda-matchers', require: false
gem 'timecop'

View file

@ -660,6 +660,8 @@ GEM
scss_lint (0.59.0)
sass (~> 3.5, >= 3.5.5)
selectize-rails (0.12.6)
selenium-devtools (0.106.0)
selenium-webdriver (~> 4.2)
selenium-webdriver (4.5.0)
childprocess (>= 0.5, < 5.0)
rexml (~> 3.2, >= 3.2.5)
@ -905,6 +907,7 @@ DEPENDENCIES
sanitize-url
sassc-rails
scss_lint
selenium-devtools
selenium-webdriver
sentry-delayed_job
sentry-rails

View file

@ -118,6 +118,10 @@ Pour exécuter les tests de l'application, plusieurs possibilités :
NO_HEADLESS=1 bin/rspec spec/system
- Afficher les logs js en error issus de la console du navigateur `console.error('coucou')`
JS_LOG=error bin/rspec spec/system
### Ajout de taches à exécuter au déploiement
rails generate after_party:task task_name

View file

@ -64,6 +64,12 @@ RSpec.configure do |config|
config.before(:each, type: :system, js: true) do
driven_by ENV['NO_HEADLESS'] ? :chrome : :headless_chrome
if ENV['JS_LOG'].present?
page.driver.browser.on_log_event(:console) do |event|
puts event.args if event.type == ENV['JS_LOG'].downcase.to_sym
end
end
end
# Set the user preferred language before Javascript system specs.