...headless chrome via Selenium. This might be useful for debugging issues with flaky integration tests or slow page simulations. page.driver.browser.network_conditions = {offline: false, latency: 5, download_throughput: 2 * 1024, upload...

...from you Rails timezone settings / system timezone. I usually have this use case in tests. Example Time.parse('2020-08-09 00:00') will return different results e.g...

When you are scrolling up to investigate a test failure it is super annoying when the terminal scrolls back down whenever the running test outputs another line. Luckily you can...

stackoverflow.com

If you want to have routes that are only available in tests (e.g. for testing obscure redirects), you can use the with_routing helper -- but that one destroys existing routes...

...may break a specs that require them to work. To keep both "regular" and test routes, do this: class MyApplicationController < ActionController::Base def show render text: 'Welcome to my application...

In Ruby you can communicate between processes with sockets. This might be helpful in tests that validate parallel executions or custom finalization logic after the garbage collector. Here is an...

bark.metacasa.net

Unfortunately, by default plugin tests are pretty bland. They use the plain unit test suite supplied by Ruby, and not any of the extended Rails test framework. This will leave...

...our plugin’s test classes with no access to fixtures, database.yml configuration, or any of those nice class auto-loading features...

In case your integration tests crash with a message like below, try to upgrade Capybara to a newer version (3.35.3 was good enough). You might encounter this issue when you...

To start a workflow manually it must have a trigger called workflow_dispatch: --- name: Tests on: push: branches: - master pull_request: branches: - master workflow_dispatch: branches: - master In the Actions...

...guaranteed to be 100% accurate. It performs a "best guess" based # on a simple test of the first +File.blksize+ characters. # # Example: # # File.binary?('somefile.exe') # => true # File.binary?('somefile.txt') # => false #-- # Based on code...

...the following command open a database console for the development environment: rails dbconsole -p test You need to write this instead: rails dbconsole test -p

justinfrench.com

If you’re testing the behavior of deprecated code in your Ruby project, the warning messages littered throughout your spec output is incredibly noisy. You could silence all warnings with...

...an important warning in one of your dependencies. It’s tempting to remove the tests altogether (the code will be burned soon too, right?), but I figured out something a...

makandra dev
github.com

...page is a collection of common markdown XSS payloads which is handy for writing tests. Producing arbitrary links: [Basic](javascript:alert('Basic')) [Local Storage](javascript:alert(JSON.stringify(localStorage))) [CaseInsensitive](JaVaScRiPt...

...REVISION', 'utf-8').trim() } catch(_error) { // okay, probably in dev mode } environment.loaders.prepend('fa-font', { test: /fa-.*\.(woff2|woff|eot|svg|ttf)$/, use: [{ loader: 'file-loader', options: { name: '[path][name]-[hash...

betterspecs.org

betterspecs.org is a documentation on how to write better RSpec tests. Note that there are also other approaches like The Self-Contained Test, which is complementary to the dry-approches...

...data to a new schema. If you have different versions, you always need to test all different version if required. With FactoryBot this should be traits. The JSON Schema files...

makandra dev

...fix" this in multiple ways: Update your drivers on your machine with RAILS_ENV=test rake webdrivers:chromedriver:update Ignore the driver update-URL in your VCR configuration

tableconvert.com

...table ("rotate" it by 90 degree). The tool can be handy if you have tests with large markdown tables for testing contents of a flat json structure or csv.

...s only minor changes but when installing major upgrades it's a good idea. Test your system after the upgrade! If you want back for some reason, you'll have...

# visit page.driver.last_request.env['HTTP_REFERER'] # old visit page.driver.request.env['HTTP_REFERER'] # new # or for javascript tests: page.execute_script('window.history.back()') end undefined method locate for #Capybara::Session (NoMethodError) Use page.find instead of...

...now wrapped by a html document skeleton. Use page.text instead. (e.g. when you are testing correct JSON which is in fact not wrapped by a html sceleton) An element can...

api.jquery.com

...of matched elements to those that match the selector or pass the function's test. jQuery has a select method, but it has nothing to do with navigating the DOM...

...MySQL console and execute SHOW TABLE STATUS FROM database; mysql> SHOW TABLE STATUS FROM test; +-------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ | Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index...

...free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment | +-------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ | test1 | MyISAM | 10 | Dynamic...

Most of these will not work in newer projects because these use the Capybara/Rack::Test combo in lieu of Webrat. Find input fields Then /^there should be a "([^"]+)" field$/ do...

...While the FULLTEXT approach was many times faster than the LIKE approach in my tests, both approaches seem to scale linearly with the number of records. For a typical web...

TL;DR Debugging problems with javascript errors in cucumber tests is sometimes easier in the browser. Run the test, stop at the problematic point (with Then pause from Spreewald...