We use Selenium WebDriver integrated with Cucumber/Capybara for full-stack integration testing. Try and use it Your forked MovieDB should already include a feature that uses a real browser. Add...

...the @javascript tag to your other features to test it yourself. When you run your cucumber feature now with NO_HEADLESS=1 geordi cucumber, you should see a browser opening...

...and show a Google map centered around it Now write an E2E feature that tests that the map shows the correct location. Hints The purpose of this lesson to learn...

...should expose an API that lets you query the current map position from your test. Your test can use evaluate_script(...) to talk with that JavaScript. Note Adding leaflet to...

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

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

...strings in locale files. This way you can override them with your own wording. Testing localization Localization is a cross-cutting concern that affects all screens.

...coverage you would need to duplicate all your tests for every single locale. This is not sustainable. We recommend the following instead: Keep most of your tests in the first...

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

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]) })

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

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

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

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

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

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

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

...explains which threads and processes interact with each other when you run a Selenium test with Capybara. This will help you understand "impossible" behavior of your tests.

...a Rack::Test (non-Javascript) test with Capybara, there is a single process in play. It runs both your test script and the server responding to the user interactions scripted...

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

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

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

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

...assist users with disabilities. It is also very practical to label things for integration tests. With the auto-mapper below you can write this: Then I should see "Bruce" within...

With this command you can run all the spec files which have been edited or added in the current branch...