...method to (un)check checkboxes. But there's one problem, if you want to test a custom styled checkbox, which hides its -Tag: The methods cannot (un)check checkboxes without...

...Some label', allow_label_click: true). Solution 2 Make hidden inputs visible in integration tests via data-environment. Depending on your CSS framework you also need to adjust the z...

When your cucumber features grow massively over time, the test execution can take a lot of time. One easy way to speed up your test execution is to use the...

...parallel_tests gem. It comes along with some useful rake tasks that let you setup your local test environment shortly to run your features, specs or unit-tests in parallel...

...that behave differently (like mobile vs desktop navigation menus). Since you want your integration tests to behave consistently, you want to set a specific size for your tests' browser windows...

...simply switch the driver via Capybara.current_driver = :selenium. If you use Cucumber for integration testing, wrap that into something like Before('@javascript') {...

Benefits of using device metrics are:

makandra dev

10.0.0 2024-03-07 Compatible changes console command: You can now globally disable the IRB multiline feature by setting irb...

If you need a sample video with certain properties for a test you can create one using ffmpeg. You might want a very low bitrate file to speed up processing...

...in your test. (e.g. you only care about the length, then you can create a video with a very low resolution and framerate) Create a 21s video with 1fps and...

We prefer to run our end-to-end tests with headless Chrome. While it's a very stable solution overall, we sometimes see the headless Chrome process freeze (or the...

...Capybara driver losing connection, we're not sure). The effect is that your test suite suddenly stops progressing without an error. You will eventually see an error after a long...

makandra dev

Just found out about a great feature in Rails that seems to be around since Rails 2. Start a console...

Jasmine has spyOnProperty(), but it only works if the property is implemented using getter and setter functions. This is a...

...your stubs, so it is always http://example.com/?foo[]=1&foo[]=2&foo[]=3. This might lead to green tests, but in fact crashes in real world. Rack::Utils.build_nested_query might help to build...

makandra dev

I recently was in a weird situation where my (Jest/CLI) tests were referencing a function that was no longer part of my code - I had just refactored it. Apparently Jest...

We currently test most of our gems on Travis CI, but want to migrate those tests to Github Actions. This is a step-by-step guide on how to do...

...Gemfiles needed which database, but is not currently very smart about it. If your test.yml does not set up the database correctly, please adjust it by comparing it with...

...usually just want to print error messages), but it can be useful when writing tests. As an example, consider the following model which uses two validations on the email attribute...

...active class switches to the clicked link. In a Jasmine spec I wanted to test this behaviour. Unpoly's up.hello emits an up:fragment:inserted event, in whose callback function...

...add logic to your application code that helps to modify the Accept-Language in tests. Here is an example for a Rails application with Cucumber integration tests: class ApplicationController

...and will cause unexpected errors with Selenium. You will see errors in your integration tests like below if you are affected by the issue: The field's content "" did not...

After removing the line above in the configuration it could happen that the tests are no longer running in headless mode. Updating the selenium-webdriver gem to >= 3.13.0 fixed...

Here is how to switch your Selenium to Chrome: Make sure you've got a recent version of chromedriver in...

whattrainisitnow.com

...subsequent ESR releases overlap for three months. This way enterprises have a quarter to test the new version and migrate their clients...

...external URL (like http://somehost.com/some/path) you will find that this is hard to test with Cucumber and Capybara: A non-Javascript Rack::Test scenario will just ignore the host...

...and try to open /some/path in your local application A Selenium test will actually follow the redirect, which you probably don't want either There are two workarounds for this...

tl;dr You can use ordered to ensure that messages are received in a specific order. Example expect(ClassA).to...

To test concurrent code, you will need to run multiple threads. Unfortunately, when you use blocking system calls (e.g. locks on the database), Ruby 1.8 threads won't work because...

@writer.puts "Started: #{i}" sleep 0.01 @writer.puts "Finished: #{i}" end @writer.close end end @writer.close # test whether we always get alternating "Started" / "Finished" lines lines = @reader.lines.to_a lines.should be_present # it...

tl;dr: Always have your attachment path start with :rails_root/storage/#{Rails.env}#{ENV['RAILS_TEST_NUMBER']}/. The directory where you save your Paperclip attachments should not look like this: storage/photos/1...

...storage/attachments/1/... storage/attachments/2/... The problem with this is that multiple environments (at least development and test) will share the same directory structure. This will cause you pain eventually. Files will get...

...callback passed to promiseState will be called asynchronously in the next microtask. Usage example: Tests Note Since this card was written Jasmine has implemented asynchronous matchers that let you expect...

...sufficient to use the then() function. Where promiseState() becomes useful is when writing unit tests for a function that returns a promise. Let's say we write a promise-based...

RSpec 1, RSpec 2 To test whether two arrays have the same elements regardless of order, RSpec 1 and 2 give you the =~ matcher: actual_array.should =~ expected_array Rspec 3

...array takes an argument, but contain_exactly takes a list of elements as varargs. Test::Unit If you install shoulda-matchers you can say: assert_same_elements([:a, :b, :c...

theprogrammingbutler.com

See the Spreewald README for more cool features. You can use it to test links that were opened with a link_to(..., :target => '_blank') link or other ways that...

...create new tabs or windows. Important This only works with Selenium enabled tests...