Skip to content

Commit 46d0dd7

Browse files
committed
[feature] access "throw 'string'" in browser console
1 parent e91c3c1 commit 46d0dd7

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
@@ -33,6 +33,7 @@ <h1>Timeout Test</h1>
3333
<h1>Console Log Test</h1>
3434
<button id="log-error">log error</button>
3535
<button id="throw-error">throw error</button>
36+
<button id="throw-raw">throw raw</button>
3637
<hr>
3738

3839
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
@@ -66,6 +67,9 @@ <h1>Console Log Test</h1>
6667
$('#throw-error').click(function() {
6768
throw new Error('error object message');
6869
});
70+
$('#throw-raw').click(function() {
71+
throw 'raw error message';
72+
});
6973
});
7074
</script>
7175
</body>

tests/PantherBrowserTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,22 @@ public function can_dump_console_log_with_throw_error(): void
159159
$this->assertStringContainsString('Error: error object message', \json_encode($output, JSON_THROW_ON_ERROR));
160160
}
161161

162+
/**
163+
* @test
164+
*/
165+
public function can_dump_console_log_with_throw_raw(): void
166+
{
167+
$output = self::catchVarDumperOutput(function() {
168+
$this->browser()
169+
->visit('/javascript')
170+
->click('throw raw')
171+
->dumpConsoleLog()
172+
;
173+
});
174+
175+
$this->assertStringContainsString('raw error message', \json_encode($output, JSON_THROW_ON_ERROR));
176+
}
177+
162178
protected function browser(): PantherBrowser
163179
{
164180
return $this->pantherBrowser();

0 commit comments

Comments
 (0)