Skip to content

Commit 6f420ae

Browse files
authored
[bug] fix debugging source when exception is detected (#88)
1 parent bd199f9 commit 6f420ae

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Browser/Session.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function source(): string
103103
try {
104104
$ret .= $this->json();
105105
} catch (DriverException $e) {
106-
$ret .= $this->page()->getContent();
106+
$ret .= \trim($this->getDriver()->getContent());
107107
}
108108

109109
return $ret;

tests/KernelBrowserTests.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,22 @@ public function can_save_formatted_json_source(): void
506506
$this->assertStringContainsString(' "content": null,', $contents);
507507
}
508508

509+
/**
510+
* @test
511+
*/
512+
public function can_save_source_when_exception(): void
513+
{
514+
$contents = self::catchFileContents(__DIR__.'/../var/browser/source/source.txt', function() {
515+
$this->browser()
516+
->visit('/invalid-page')
517+
->assertStatus(404)
518+
->saveSource('/source.txt')
519+
;
520+
});
521+
522+
$this->assertStringContainsString('No route found for', $contents);
523+
}
524+
509525
/**
510526
* @test
511527
*/

0 commit comments

Comments
 (0)