...limited to 3 e-mails per day. Further reading ActionMailer: How to send a test mail directly from the console Debugging SPF records
Download buttons can be difficult to test, especially with Selenium. Depending on browser, user settings and response headers, one of three things can happen: The browser shows a "Save as...
...through Selenium. The browser automatically downloads the file without prompting the user. For the test it looks like nothing has happened. The browser shows a binary document in its own...
A flaky test is a test that is often green, but sometimes red. It may only fail on some PCs, or only when the entire test suite is run.
...are many causes for flaky tests. This card focuses on a specific class of feature with heavy side effects, mostly on on the UI. Features like the following can amplify...
An end-to-end test (E2E test) is a script that remote-controls a web browser with tools like Selenium WebDriver. This card shows basic techniques for fixing a flaky...
...and seed per process: DISPLAY=:17 bundle exec parallel_cucumber --serialize-stdout --verbose-process-command --test-options '--order random' features/ bin/cucumber --order random --profile parallel features/location/import.feature features/location/export.feature Using the parallel...
By default parallel_tests will spawn as many test processes as you have CPUs. If you have issues with flaky tests, reducing the number of parallel processes may help.
...Flaky test suites can and should be fixed. This card is only relevant if you need to run a flaky test suite that you cannot fix for some reason. If...
A JavaScript error in an E2E test with Selenium will not cause your test to fail. This may cause you to miss errors in your frontend code. Using the BrowserConsole...
...helper below you can check your browser's error console from your E2E tests. The following will raise BrowserConsole::ErrorsPresent if there is an error on the browser console: BrowserConsole.assert...
Test-Driven Development (TDD) in its most dogmatic form (red-green-refactor in micro-iterations) can be tedious. It does not have to be this way! This guide shows a...
...start writing them out and implementing them. As with the integration tests, the order of test-writing and implementation is up to you. When you're done, return to writing...
When ending a Selenium test Capybara resets the browser state by closing the tab, clearing cookies, localStorage, etc. It may be a good idea to wait for all in-flight...
...If that JavaScript opens an error alert or spams errors to the console, your test may fail after the last step. With unlucky timing the server may receive an AJAX...
...Looking at the hidden browser Option 1: Run without headless You can call your tests with NO_HEADLESS=1 bundle exec cucumber to see the Chrome window for this test...
...fork TCP4:127.0.0.1:9223 (if missing, install the socat package) Start you integration test e.g. REMOTE_DEBUGGING=1 bundle exec rspec spec/system/some_spec.rb with a debugger set Open chrome://inspect/. It...
Jasmine is a great way to unit test your JavaScript components without writing an expensive end-to-end test for every small requirement. After we integrated Jasmine into a Rails...
...app we often add an E2E test that opens that Jasmine runner and expects all specs to pass. This way we see Jasmine failures in our regular test runs.
...so you can build on previous scripts for a similar task You can have tests (see below) Although not part of the application, your script is code and should adhere...
...ActiveRecord::RecordInvalid # Handle error end On error, log the record for manual care. Consider testing your script Not every script needs a test. However, sometimes you'll want to add...
Both knapsack and parallel_tests have the option to split groups by historic execution time. The required logs for this might be outdated since you manually have to update and...
...no extra effort locally and/or remotely. How to always split by execution logs Parallel Tests The parallel_tests gem has the option flag --group-by to change the default splitting...
In most projects I know, Cucumber test suite speed is not an issue. Of course, running 350 features takes its time, but still each test for itself is reasonably fast...
...There is nothing you can do to fundamentally speed up such a test (of course, you should be using parallel_tests). However, in projects that go beyond clicking around in...
Getting an entire test suite green can be a tedious task which involves frequent switches between the CLI that is running tests back to the IDE where its cause can...
...example_status_persistence_file_path as it allows RSpec to keep track of failing tests. See this card for set-up instructions. If you don't use RSpec for all...
When your Rails application server raises error, Capybara will fail your test when it clears the session after the last step. The effect is a test that passes all steps...
When you need test images, instead of using services like lorempixel or placehold.it you may generate test images yourself. Here we build a simple SVG image and wrap it into...
...index in your migration and migrate add_index :users, [:last_name, :created_at] 3. Test the index in your database ActiveRecord::Base.connection.execute('SET enable_seqscan = OFF') # Try to force index...
...Yourself (or DRY if you prefer). Identical blocks of code to set up a test sure does look like repetition, so we extract it into a before block.
...a mistake for tests. The article explains about how sharing setup between examples make test files harder to read and evolve. A related frustration I have is working on ultra...
Testing file download links in an end-to-end test can be painful, especially with Selenium. The attached download_helpers.rb provides a download_link method for your Capybara tests. It returns...
...other approaches this helper has many useful features: Works with both Selenium and Rack::Test drivers without limitations. Understands the [download] and [download=filename.ext] attributes. Allows filename, disposition, content type...
For my computer science bachelor's thesis I programmed and evaluated a CLI Test Case Prioritization (TCP) tool for makandra. It has been written as a Ruby Gem and was...
...modifications, to prioritize test cases which might be failing due to these modifications. Newly added test-cases have to granted high priority within the calculated prioritization. Test Case Prioritization
...DOM elements often leave elements in the DOM after they're done. This will leak test-local DOM state to subsequent tests. For example, this test creates a element, runs...
...butler did it') }) }) To address this I like to configure a global container for test elements, which is cleared automatically after each test. By including the following helper hooks your...
Timecop is a great gem to set the current time in tests. However, it is easy to introduce flakyness to your test suite when you forget to reset the time...
...after the test. This might be the case if: a test freezes time and a later test does not work for frozen time a later test needs the real current...
If you already selected an element and want to get its parent, you can call find(:xpath, '..') on it.
I recently noticed a new kind of flaky tests on the slow free tier GitHub Action runners: Integration tests were running on smaller screen sizes than specified in the device...
...browser_to(MOBILE_WIDTH, MOBILE_HEIGHT) else # Nothing to do in case of rack tests end end end This could however reduce your test performance...