Level 5
A workaround seems to be:
$logs = $frame->driver->manage()->getLog('browser');
dump($logs);
1 like
I'm trying to use dusk's storeConsoleLog() to capture some Javascript errors whilst debugging a test.
I'm sure I've had this method working before but now nothing is getting written to disk although there are definitely console errors. I've even broken something on my front end to force a console error.
Here's my test in case I've missed something obvious:
public function test_send_message(): void
{
$user = User::factory()->create();
Auth::login($user);
$conversation = $this->setUpTestConversation($user);
$conversation->otherParticipants($user)->first();
$this->browse(function (Browser $frame) use( $user, $conversation) {
//check conversation is loaded, fill in the message and send
$frame
->loginAs($user)
->visit(route('conversation.show', $conversation->id))
->assertPresent('@show-message-new')
->with('@show-message-new', function ($message) {
$message->type('@dynamic_text_input','This is a normal text message')
->click('@message_post')
->waitUntilDisabled('@button_standard')
->waitUntilEnabled('@button_standard');
});
//check the database first
$this->assertDatabaseHas('messages', [
'conversation_id' => $conversation->id,
'user_id' => $user->id,
'message' => 'This is a normal text message'
]);
dump($frame->text('@show-message-messages'));
$frame->storeConsoleLog('errors.log');
//check the message is there
$frame->waitForTextIn('@show-message-messages', 'This is a normal text message', 60);
//now try an empty message and get an error
$frame->with('@show-message-new', function ($message) {
$message
->click('@message_post')
->waitFor('@show-message-error');
});
//now try with html to make sure it works as exact text
$frame->with('@show-message-new', function ($message) {
$message->type('@dynamic_text_input','<a href="dodgy"> Link </a>')
->click('@message_post');
});
$frame->waitForTextIn('@show-message-messages','<a href="dodgy"> Link </a>');
});
}
A workaround seems to be:
$logs = $frame->driver->manage()->getLog('browser');
dump($logs);
Please or to participate in this conversation.