Repository: govuk_test
GOV.UK test dependencies & configuration
- GitHub
- govuk_test
- Ownership
- #govuk-platform-engineering owns the repo. #govuk-platform-support receives automated alerts for this repo.
- Category
- Gems
We’d like to set some cookies to understand how you use this site and remember your settings.
We also use cookies set by other sites to help us deliver content from their services.
You have accepted additional cookies. You can change your cookie settings at any time.
You have rejected additional cookies. You can change your cookie settings at any time.
GOV.UK test dependencies & configuration
Gem to package test dependencies and config for GOV.UK applications. Cousin of govuk_app_config.
gem "govuk_test"
And then execute:
$ bundle
Somewhere in your spec_helper.rb
, rails_helper.rb
, or
spec/support/govuk_test.rb
put:
GovukTest.configure
This will configure Capybara to run any JavaScript enabled tests against a Selenium driven instance of headless Google Chrome.
If you need to use this as a root user (such as within some docker containers)
you will need to set a GOVUK_TEST_CHROME_NO_SANDBOX
environment variable.
You can reuse the Selenium options for headless Google Chrome for configuring other Selenium driven tests, such as Jasmine:
class ChromeHeadlessJasmineConfigurer < JasmineSeleniumRunner::ConfigureJasmine
def selenium_options
{ options: GovukTest.headless_chrome_selenium_options }
end
end
Should you need to configure the options for your application the recommended approach is to re-register the headless Google Chrome driver:
GovukTest.configure
Capybara.register_driver :headless_chrome do |app|
chrome_options = GovukTest.headless_chrome_selenium_options
chrome_options.add_argument("--disable-web-security")
chrome_options.add_argument("--window-size=1400,1400")
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
desired_capabilities: { acceptInsecureCerts: true },
options: chrome_options,
)
end
The gem is available as open source under the terms of the MIT License.