Skip to content

Commit

Permalink
[feature] access "throw 'string'" in browser console
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Aug 11, 2022
1 parent ea84ec6 commit e90dee8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/Fixture/files/javascript.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ <h1>Timeout Test</h1>
<h1>Console Log Test</h1>
<button id="log-error">log error</button>
<button id="throw-error">throw error</button>
<button id="throw-raw">throw raw</button>
<hr>

<a style="display: none;" href="/page1">invisible link</a>
Expand Down Expand Up @@ -68,6 +69,9 @@ <h1>Console Log Test</h1>
$('#throw-error').click(function() {
throw new Error('error object message');
});
$('#throw-raw').click(function() {
throw 'raw error message';
});
});
</script>
</body>
Expand Down
16 changes: 16 additions & 0 deletions tests/PantherBrowserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,22 @@ public function cannot_follow_invisible_link(): void
;
}

/**
* @test
*/
public function can_dump_console_log_with_throw_raw(): void
{
$output = self::catchVarDumperOutput(function() {
$this->browser()
->visit('/javascript')
->click('throw raw')
->dumpConsoleLog()
;
});

$this->assertStringContainsString('raw error message', \json_encode($output, JSON_THROW_ON_ERROR));
}

protected function browser(): PantherBrowser
{
return $this->pantherBrowser();
Expand Down

0 comments on commit e90dee8

Please sign in to comment.