In some projects we have issues with flaky tests. The best default is to fix them all. But in some cases it might be a pragmatic way to retry them...

...for a limit number of times. Notes: This setup was tested with a CI Pipeline that uses knapsack for parallel test balacing The official docs recommend to use rspec-retry...

...you integrate geocoding, maps and a title-autocomplete API from JavaScript, and learn to test code that talks to external services. Important Work on this lesson in builder mode.

...from the browser to enrich your UI. You can design your JavaScript so a test can query its state through a small API, and drive it from a feature spec...

evilmartians.com

...prefer writing your own code for simple requirements without many edge cases) Gem is tested well (coverage and quality) Gem has a good code quality Gem's licence fits to...

ruby-doc.org

...be an issue, but can be annoying to deal with during development and in tests. To avoid this use Rationals conversion_factor = Rational('1') / Rational('3.6') # => (5/18) result = Rational...

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...

Whenever you have to deal with randomness in a jasmine test there are some spy strategies to help you out! Let's say we have a method Random.shuffle(array) to...

...shuffles the array', () => { spyOn(Random, 'shuffle').and.returnValue([3, 2, 1]) array = [1, 2, 3] testedClass = new testedClass(array) expect(Random.shuffle).toHaveBeenCalled() expect(testedClass.array).toEqual([3, 2, 1]) })

...attributes makes it easier to find errors in your application during development and in tests. Consider this approach if you want to strengthen the params handling in your application.

...the user is missing permit(:full_name) logs the error ActionController::UnpermittedParameters in development + test and do nothing in production. Option 1: In case you use action_on_unpermitted_parameters...

stevenhicks.me

Sometimes you want to write a test for a business rule that's based on multiple variables. In your goal to cover the rule thoroughly, you start writing tests for...

...business rule, you get 2n permutations/test cases. This is manageable with 2 variables (4 test cases), but at 3 variables (8 test cases) it becomes ridiculous, and anything beyond that...

When you repeat complex assertions in your tests multiple times, it might be a good idea to extract a custom RSpec matcher. This not only tidies up your own code...

...controllers' #index actions. This way, when a change introduces an n+1 query, your test suite will blow up. Example A typical #index action looks like this. class CardsController < ApplicationController...

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...

...einfachen Weg dieses Problem zu vermeiden. Verwende Docker Compose um die Applikation lokal zu testen. Erweitere die bestehende docker-compose.yml. Die vorhandene Datei ist nicht optimal konfiguriert, achte darauf das auch...

...ein terraform plan ausgeführt werden Erstelle einen CI Job der in Merge Requests die Tests laufen lässt. Beachte, dass dafür ein laufender PostgreSQL benötigt wird und die Zugangsdaten per Environment...

To navigate between test and test subject Rubymine requires you to set the test root sources as Test Sources Root. In case you are using the keyboard shortcut "CTRL + ALT...

...SHIFT + c" to copy the reference path + you have set the "Test Sources Root" for your test folders, you might consider setting this keyboard to "Copy From Repository Root". This...

Geordi can also be configured to automatically update chromedriver each time you run tests. For that, edit the global configuration file ~/.config/geordi/global.yml and add the line auto_update_chromedriver...

...use it, why it is useful even for single-language apps, and how to test it. Important Work on this lesson in builder mode. Learning goals You can explain what...

...the URL — and explain the trade-offs of each. You can explain a sensible testing strategy for localization: most tests in one language, explicit tests for switching and for non...

...to remove the same YAMLs file before you can re-run that still-red test. With this little helper, you (or your coding agent) can do the same with RE...

edgeapi.rubyonrails.org

The linked article suggests an interesting way to speed up tests of Rails + Postgres apps: PostgreSQL allows the creation of “unlogged” tables, which do not record data in the PostgreSQL...

...production environments. If you would like all created tables to be unlogged in the test environment you can add the following to your test.rb file: # config/environments/test.rb ActiveSupport.on_load(:active_record...

...show a "Choose your search engine" popup in Europe. This might make your Cucumber tests fail. Fortunately there is a flag to disable the popup. Add the following option to...

...I use git worktree? You can use more than one working tree to ... ... run tests while working on another branch ... compare multiple versions ... work on a different branch without disturbing...

...cookies. These are normal, signed and encrypted cookies. By following the happy path of testing a web application, that is only the main use-case is tested as a integration...

...test and the rest as isolated (more unit like) tests, one might want to test some cookie dependent behavior as a request, helper or model spec too. Since the rspec...

Imagine you want to write a cucumber test for a user-to-user chat. To do this, you need the test to work with several browser sessions, logged in as...

...of their file paths by default (or when you specify --order defined). You run tests in random order by using --order random on the command line, or by putting it...

...your project's .rspec file. Note that both switches also affect the order the tests inside each file are run: defined runs tests in the order they are defined inside...

testing-library are widely used testing utilities libraries for javascript dependent frontend testing. The main utilities provided are query methods, user interactions, dom expectations and interacting with components of several...

...less about the details happening in the browser and focus more on user centric tests instead! Some of the time you will find a necessity to use methods like waitFor...

makandra dev

...environment configuration. This is useful for keeping log files manageable, especially in development and test environments. # config/environments/development.rb Rails.application.configure do config.log_file_size = 10.megabytes end When this value is set, Rails...