Skip to content

Commit e91c3c1

Browse files
committed
[minor] test that browser console can capture "throw Error"
1 parent dc52c86 commit e91c3c1

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

tests/Fixture/files/javascript.html

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ <h1>Timeout Test</h1>
3232

3333
<h1>Console Log Test</h1>
3434
<button id="log-error">log error</button>
35+
<button id="throw-error">throw error</button>
3536
<hr>
3637

3738
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
@@ -62,6 +63,9 @@ <h1>Console Log Test</h1>
6263
$('#log-error').click(function() {
6364
console.error('console.error message');
6465
});
66+
$('#throw-error').click(function() {
67+
throw new Error('error object message');
68+
});
6569
});
6670
</script>
6771
</body>

tests/PantherBrowserTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,22 @@ public function can_dump_console_log_with_console_error(): void
143143
$this->assertStringContainsString('console.error message', \json_encode($output, JSON_THROW_ON_ERROR));
144144
}
145145

146+
/**
147+
* @test
148+
*/
149+
public function can_dump_console_log_with_throw_error(): void
150+
{
151+
$output = self::catchVarDumperOutput(function() {
152+
$this->browser()
153+
->visit('/javascript')
154+
->click('throw error')
155+
->dumpConsoleLog()
156+
;
157+
});
158+
159+
$this->assertStringContainsString('Error: error object message', \json_encode($output, JSON_THROW_ON_ERROR));
160+
}
161+
146162
protected function browser(): PantherBrowser
147163
{
148164
return $this->pantherBrowser();

0 commit comments

Comments
 (0)