Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD / After each step we wait for the server to handle all requests #185

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/Context/SilverStripeContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SilverStripe\BehatExtension\Context;

use Behat\Behat\Hook\Scope\AfterStepScope;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Mink\Element\NodeElement;
use Behat\Mink\Exception\ElementNotFoundException;
Expand Down Expand Up @@ -276,6 +277,27 @@ public function before(BeforeScenarioScope $event)
}
}

/**
* @AfterStep
*
* Wait for all requests to be handled after each step
*
* @param AfterStepScope $event
*/
public function waitResponsesAfterStep(AfterStepScope $event)
{
$success = $this->testSessionEnvironment->waitForPendingRequests();
if (!$success) {
echo (
maxime-rainville marked this conversation as resolved.
Show resolved Hide resolved
'Warning! The timeout for waiting a response from the server has expired...'.PHP_EOL.
'I keep going on, but this test behaviour may be inconsistent.'.PHP_EOL.PHP_EOL.
'Your action required!'.PHP_EOL.PHP_EOL.
'You may want to investigate why the server is responding that slowly.'.PHP_EOL.
'Otherwise, you may need to increase the timeout.'
);
}
}

/**
* Returns a parameter map of state to set within the test session.
* Takes TESTSESSION_PARAMS environment variable into account for run-specific configurations.
Expand Down