Debugging your integration tests, that run a headless Chrome inside a docker image, is tricky. In many cases you can connect your Chrome to a remote docker container like docker...

...be the preferred way when you try to inspect a page within your integration test. Otherwise you might be able to start your docker container with --net=host and access...

When using Chrome for Selenium tests, the chromedriver binary will be used to control Chrome. To debug problems that stem from Selenium's Chrome and/or Chromedriver, you might want to...

...the chromedriver itself. Here is how. Option 1: Use Selenium::WebDriver::Service In your test setup, you may already have something like Capybara::Selenium::Driver.new(@app, browser: :chrome, options: ...), especially...

...tool. This helps you to find out which parts of your application are not tested. Integrating this in a rails project with rspec, cucumber and parallel_tests is easy.

...it to your Gemfile and bundle group :test do gem 'simplecov', require: false end Add a .simplecov file in your project root: SimpleCov.start 'rails' do # any custom configs like groups...

github.com

Internet Explorer until version 9 has some limitations when parsing CSS files Summarized, these are: Up to 31 CSS files...

...To improve this, I have successfully been using a little "step" helper in my tests. It marks semantic sections, structuring an example while improving documentation. When the test runs, each...

...spec, as well as tracking progress during execution. # # Example: # it 'offers a login' do # # Test setup # # STEP 'Attempt login with wrong credentials' # # ... # # STEP 'Successful login' # # ... # end def STEP(label) formatters...

Capistrano is by default configured to exclude the gems of the groups development and test when deploying to the stages production and staging. Whenever you create custom groups in your...

...deploy, add the following to config/deploy/production.rb and config/deploy/staging.rb respectively: set :bundle_without, %w{development test cucumber deploy}.join(' ') Be aware, that gems that belong to two groups, are only excluded...

...trashed_changed? end Or, move the conditions into the callback. This also allows you test the conditions more easily using a unit test: after_save :update_offices_people_count

if office_id_changed? || trashed_changed? ... end end Also see the card on testing conditional validations...

...instead reference another part of that email by a content ID cid:xxxxx@xxxxx.mail. Your tests will not be able to verify easily that you used the correct image version any...

...last point, it is recommended to use a feature flag and disable inlining in tests by default so you will still be able to easily test that your emails use...

Geordi's cucumber command has a --rerun option that reruns failing tests the given number of times. Usage: geordi cucumber path/to/features --rerun=2 geordi cucumber path/to/features -r2 Background and how...

...tmp/parallel_cucumber_failures.log containing the filenames and line number of the failed scenarios after a full test run. Normally you can say cucumber -p rerun (rerun is a profile defined by default...

...data-environment=<%= Rails.env %>> Now you can say in a piece of Javascript: if (document.documentElement.dataset.environment == 'test') { // Code that should happen in Selenium tests } else { // Code that should happen for other environments...

...Or in your CSS / Sass: html[data-environment="test"] { * { text-transform: none !important; } } See also Cucumber: Detect if the current Capybara driver supports Javascript

github.com

The issue: You are using stub_const to change a constant value for your test. stub_const "SomeClass::CONST", 'test' All of a sudden, tests fail with undefined method 'some...

...workaround, use stub_const in your Rails specs like this: stub_const "#{SomeClass}::CONST", 'test' This will invoke Rails' autoloading and fix RSpec's behavior for you...

makandra dev

...Binding URL with the LogoutResponse. Keycloak does this when Front channel logout is disabled. Testing in development using a local keycloak server You can test this using a local keycloak...

...and is enabled per default This just worked for me, so no troubleshooting here Testing in development using a local keycloak server You can test this using a local keycloak...

config.move_to_store = true We have a separate card about that. Store test files separately. Also add support for parallel tests. You can easily do that by setting...

config.root = "#{Rails.public_path}/system/#{Rails.env}#{ENV['TEST_ENV_NUMBER']}".freeze For debugging purposes (e.g. trying to hunt down a staging bug locally), it might make sense to allow reading...

baz: "example" We can now load it as usual, but pass freeze: true. >> test = YAML.safe_load_file('example.yml', freeze: true) => {"message"=>["hello", "universe"], "foo"=>{"bar"=>{"baz"=>"example"}}}

...itself is frozen: >> test.frozen? => true And no matter how deep you dig, everything inside that Hash is also frozen. >> test['message'].frozen? => true >> test['foo']['bar']['baz'].frozen? => true

github.com

...What you can do is change the time zone of the process running your tests by setting a TZ=CET (or TZ=PDT or TZ=UTC etc.) environment variable.

...way, when the test process spawns another process to run a browser, it will inherit the environment and also believe it lives in that zone. To do so, run the...

...default for building is production. Activate an environment with -e staging or --environment=staging. Test for environments like this: environment? :staging Testing Complex "static" pages might need some integration testing...

...To employ Cucumber with Spreewald and Selenium, add these gems to the Gemfile: group :test do gem 'cucumber' gem 'spreewald' gem 'capybara' gem 'selenium-webdriver' # Only for running tests in...

getbootstrap.com

Suggestion: Upgrade to a newer version before doing the Bootstrap upgrade and test if everything still works as expected. Here is a migration guide for Select2

...navigation on your own. Tip: Add a feature for your navigation bar beforehand and test links and their highlighting (don't forget dropdown submenus!). After upgrading to Bootstrap 4 you...

...verification") added without_partial_double_verification. This might be handy in case you are testing helpers in Rails, where you sometimes rely on methods defined in the application controller (e.g...

...module UsersHelper def user_display_name [current_user.first_name, current_user.last_name].join(' ') end end Unit test with error describe UsersHelper do describe '#user_display_name' do it 'returns the first and...

makandra dev

...do not need a code review, but use the merge request to run a test pipeline: # Push branch, create a merge request, set the branch to be removed on merge...

...and set to merge when all tests are green ptm = push -u origin HEAD -o merge_request.create -o merge_request.merge_when_pipeline_succeeds -o merge_request.remove_source_branch Miscellaneous [core] editor = vim # Set...

...than Dir.tmpdir e.g. Dir.mktmpdir('foo', Rails.root.join('tmp')) => /home/user/rails_example/tmp/foo20220912-14561-pyr8qd. This might be necessary when your tests are running on CI. For this you might also want to commit tmp/.gitkeep to git...

...tmp dir inside your project is present. Example Dir.mktmpdir('exports') => "/tmp/exports20220912-14561-pobh0a" Improving your parallel tests with Dir.mktmpdir When creating directories in parallel tests manually, you normally need to handle these...

...close them as well! See the suggested helper at the bottom of this card. Test support If you access Redis in tests, I suggest introducing a helper method. Example for...

...redis ||= Redis.new(url: REDIS_URL) end end RSpec.configure do |config| config.include(RedisHelpers) end Your Tests may then say redis.get('example'). But I still want to use a global

...navigate to Settings -> Editor -> File and Code Templates. Example You can navigate to the test file of the currently open file with the shortcut Ctrl + T. If no test file...

...exists, you can generate a new test file. If you are not pleased with the output, you can adjust the related code template. To do this, open the project settings...

...and expected constants are resolved: class_name = params[:type].presence_in(%w[User Post Test]) if class_name class_name.safe_constantize.new # either User, Post or Test else Rails.logger.error "This should not happen...

thegnar.com

View specs are a powerful tool to test several rendering paths by their cases instead of using a more costing feature spec. This is especially useful because they become quite...

...the view independent from the controller-logic. Therefore it will be more applicable to test views within request specs. But, even then, you still can use Caypbara's matchers within...