A platform for community discussion. Free, open, simple.
DEV: Skip CSS watcher when running QUnit tests and expose more Chrome logs (#13390)
Osama Sayegh503017474c93
diff --git a/config/environments/development.rb b/config/environments/development.rbindex 0c7810dccf9..7e58350de6d 100644--- a/config/environments/development.rb+++ b/config/environments/development.rb@@ -84,7 +84,7 @@ Discourse::Application.configure doconfig.developer_emails = emails.split(",").map(&:downcase).map(&:strip)end- if defined?(Rails::Server) || defined?(Puma) || defined?(Unicorn)+ if ENV["DISCOURSE_SKIP_CSS_WATCHER"] != "1" && (defined?(Rails::Server) || defined?(Puma) || defined?(Unicorn))require 'stylesheet/watcher'STDERR.puts "Starting CSS change watcher"@watcher = Stylesheet::Watcher.watchdiff --git a/lib/tasks/qunit.rake b/lib/tasks/qunit.rakeindex bbeaba819ef..34ac6c3d6bf 100644--- a/lib/tasks/qunit.rake+++ b/lib/tasks/qunit.rake@@ -49,7 +49,8 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|"SKIP_ENFORCE_HOSTNAME" => "1","UNICORN_PID_PATH" => "#{Rails.root}/tmp/pids/unicorn_test_#{port}.pid", # So this can run alongside development"UNICORN_PORT" => port.to_s,- "UNICORN_SIDEKIQS" => "0"+ "UNICORN_SIDEKIQS" => "0",+ "DISCOURSE_SKIP_CSS_WATCHER" => "1"},"#{Rails.root}/bin/unicorn -c config/unicorn.conf.rb",pgroup: truediff --git a/test/run-qunit.js b/test/run-qunit.jsindex 67dbc8157bf..f55a9d70b0d 100644--- a/test/run-qunit.js+++ b/test/run-qunit.js@@ -75,7 +75,19 @@ async function runAllTests() {}}- const { Inspector, Page, Runtime } = protocol;+ const { Inspector, Page, Runtime, Log } = protocol;++ // Documentation https://chromedevtools.github.io/devtools-protocol/tot/Log/#type-LogEntry+ Log.enable();+ Log.entryAdded(({ entry }) => {+ let message = `${new Date(entry.timestamp).toISOString()} - (type: ${+ entry.source+ }/${entry.level}) message: ${entry.text}`;+ if (entry.url) {+ message += `, url: ${entry.url}`;+ }+ console.log(message);+ });// eslint-disable-next-lineawait Promise.all([Inspector.enable(), Page.enable(), Runtime.enable()]);