Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Created January 3, 2024 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziadoz/ecda21aa8478cbe51197a444aa3ccf6b to your computer and use it in GitHub Desktop.
Save ziadoz/ecda21aa8478cbe51197a444aa3ccf6b to your computer and use it in GitHub Desktop.
Laravel Dusk - Disable Bootstrap 4 CSS Transitions
<?php
namespace Tests\Browser;
use Tests\DuskTestCase;
class ModalTest extends DuskTestCase
{
public function test_modal(): void
{
$this->browse(function (Browser $browser) {
$browser->visit('/modal');
// Disable modal CSS transitions because they interfere with clicking the close button.
$browser->script(<<<SCRIPT
document.head.insertAdjacentHTML('beforeend', '<style>* { transition: none !important; transform: none; }<style>');
SCRIPT);
// Open the modal.
$browser->click('a.open-modal');
// Perform some assertions.
$browser->whenAvailable('div.modal-dialog', function (Browser $browser) use ($position) {
// Do stuff...
});
// Close the modal.
// Without disabling the transitions, this would fail because things occur so quickly.
$browser->click('div.modal-dialog button.close');
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment