How to ensure there are no errors on a page

An easy way to check for errors is to open the browser console log. But that’s not so easy to automate, right? Actually it’s fairly easy. If you’re testing in Magium you can execute an assertion to validate that the browser log is empty, indicating that there are no errors on the page.

It’s really easy to do.

use Magium\AbstractTestCase;
use Magium\Assertions\Browser\LogEmpty;

class BrowserLogTest extends AbstractTestCase
{

    public function testLogIsEmpty()
    {
        $this->commandOpen($this->getTheme()->getBaseUrl());

        $assertion = $this->getAssertion(LogEmpty::ASSERTION);
        /* @var $assertion LogEmpty */
        $assertion->assert();
    }
}