Last Updated: February 25, 2016
·
921
· webbj74

Alter the curl timeout when using behat mink extension and goutte

Problem:

Behat tests fail with messages like:

[curl] 28: Operation timed out after 30096 milliseconds with 0 bytes received

Reason:

By default, goutte sets CURLOPT_TIMEOUT to 30 seconds

Solution:

You can alter CURLOPT_TIMEOUT universally in your behat tests by adding a "guzzle_parameters" subsection to your goutte definition

In the example below I set the timeout to 60 seconds to deal with a page expected to take longer than 30s to load.

default:
  paths:
    features: tests/features
    bootstrap: %behat.paths.features%/bootstrap
  extensions:
    Behat\MinkExtension\Extension:
      goutte:
        guzzle_parameters:
          curl.options:
            CURLOPT_TIMEOUT: 60
      selenium2: ~
      base_url: http://127.0.0.1:8080/
    Drupal\DrupalExtension\Extension:
      blackbox: ~
      drush:
        root: docroot

References: