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

Added more logging to JavaScript logs #105

Closed
wants to merge 2 commits into from
Closed
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
15 changes: 13 additions & 2 deletions src/lib/Browser/Context/DebuggingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
use Behat\Behat\Hook\Scope\AfterStepScope;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Behat\Hook\Scope\BeforeStepScope;
use Behat\Mink\Session;
use Behat\MinkExtension\Context\RawMinkContext;
use Behat\Testwork\Tester\Result\TestResult;
use Ibexa\Behat\Core\Log\Failure\TestFailureData;
use Ibexa\Behat\Core\Log\KnownIssuesRegistry;
use Ibexa\Behat\Core\Log\TestLogProvider;
use Psr\Log\LoggerInterface;

class DebuggingContext extends RawMinkContext
final class DebuggingContext extends RawMinkContext
{
/** @var \Psr\Log\LoggerInterface */
private $logger;
Expand All @@ -30,44 +31,54 @@ class DebuggingContext extends RawMinkContext
/** @var \Ibexa\Behat\Core\Log\KnownIssuesRegistry */
private $knownIssuesRegistry;

/** @var \Behat\Mink\Session */
private $session;

/** @var \Behat\Testwork\Tester\Result\TestResult */
private $failedStepResult;

public function __construct(
LoggerInterface $logger,
string $logDir,
KnownIssuesRegistry $knownIssuesRegistry
KnownIssuesRegistry $knownIssuesRegistry,
Session $session
) {
$this->logger = $logger;
$this->logDir = $logDir;
$this->knownIssuesRegistry = $knownIssuesRegistry;
$this->session = $session;
}

/** @BeforeScenario
*/
public function logStartingScenario(BeforeScenarioScope $scope)
{
$text = sprintf('console.error("Starting Scenario: %s")', $scope->getScenario()->getTitle());
$this->session->executeScript($text);
$this->logger->error(sprintf('Behat: Starting Scenario "%s"', $scope->getScenario()->getTitle()));
}

/** @BeforeStep
*/
public function logStartingStep(BeforeStepScope $scope)
{
// $this->session->executeScript(sprintf('console.error("Starting Step: %s")', $scope->getStep()->getText()));
$this->logger->error(sprintf('Behat: Starting Step "%s"', $scope->getStep()->getText()));
}

/** @AfterScenario
*/
public function logEndingScenario(AfterScenarioScope $scope)
{
// $this->session->executeScript(sprintf('console.error("Ending Scenario: %s")', $scope->getScenario()->getTitle()));
$this->logger->error(sprintf('Behat: Ending Scenario "%s"', $scope->getScenario()->getTitle()));
}

/** @AfterStep
*/
public function logEndingStep(AfterStepScope $scope)
{
// $this->session->executeScript(sprintf('console.error("Ending Step: %s")', $scope->getStep()->getText()));
$this->logger->error(sprintf('Behat: Ending Step "%s"', $scope->getStep()->getText()));

if ($scope->getTestResult()->isPassed()) {
Expand Down
Loading