From f16172ee3377e05fd08ca9c4fd55649457402cde Mon Sep 17 00:00:00 2001 From: Scott Ries Date: Tue, 13 Aug 2024 13:52:47 -0400 Subject: [PATCH] fix: add `Lazy-load Axe::API::Run` to improve boot time (#396) It saves 95% of load time when doing `require "axe-rspec"`. The time is actually spent loading the `virtus` library. Deferring the loading of `Axe::API::Run` until needed does in turn defer the loading of `virtus` library. No QA required. --------- Co-authored-by: Christophe Bliard --- .circleci/config.yml | 2 +- packages/axe-core-api/e2e/selenium/spec/api_spec.rb | 4 ++-- packages/axe-core-api/lib/axe/api.rb | 5 +++++ packages/axe-core-api/lib/axe/matchers/be_axe_clean.rb | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 packages/axe-core-api/lib/axe/api.rb diff --git a/.circleci/config.yml b/.circleci/config.yml index 71b22747..6bb370fe 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,7 @@ defaults: &defaults working_directory: ~/axe-core-gems orbs: - browser-tools: circleci/browser-tools@1.4.3 + browser-tools: circleci/browser-tools@1.4.8 node: circleci/node@5.0.0 commands: diff --git a/packages/axe-core-api/e2e/selenium/spec/api_spec.rb b/packages/axe-core-api/e2e/selenium/spec/api_spec.rb index ee2a78dc..ddfb090f 100644 --- a/packages/axe-core-api/e2e/selenium/spec/api_spec.rb +++ b/packages/axe-core-api/e2e/selenium/spec/api_spec.rb @@ -2,10 +2,10 @@ require "json" #TODO: REMOVE require "selenium-webdriver" require "axe/core" -require "axe/api/run" +require "axe/api" options = Selenium::WebDriver::Chrome::Options.new -# options.add_argument('--headless') +options.add_argument('--headless') options.add_argument('--no-sandbox') options.add_argument('--disable-dev-shm-usage') $driver = Selenium::WebDriver.for :chrome, options: options diff --git a/packages/axe-core-api/lib/axe/api.rb b/packages/axe-core-api/lib/axe/api.rb new file mode 100644 index 00000000..75ca0c26 --- /dev/null +++ b/packages/axe-core-api/lib/axe/api.rb @@ -0,0 +1,5 @@ +module Axe + module API + autoload :Run, "axe/api/run" + end +end diff --git a/packages/axe-core-api/lib/axe/matchers/be_axe_clean.rb b/packages/axe-core-api/lib/axe/matchers/be_axe_clean.rb index e7065f6d..d7dfc5f3 100644 --- a/packages/axe-core-api/lib/axe/matchers/be_axe_clean.rb +++ b/packages/axe-core-api/lib/axe/matchers/be_axe_clean.rb @@ -2,7 +2,7 @@ require_relative "../../chain_mail/chainable" require_relative "../core" -require_relative "../api/run" +require_relative "../api" module Axe module Matchers