dev-master
9999999-dev
The Requires
- php >=5.4
- behat/behat 3.*
- behat/mink-extension *@dev
by Thomas Subera
JS Error Logger Context for Behat 3., (*1)
The Context extends from Mink and was tested with the selenium2 driver. Basically it looks after every Step if there is an error present., (*2)
To get this working you need to add a js snippet into the html code of your project., (*3)
The Context was tested soley with the selenium2 driver. There can be Situations that the check for js errors after a step can break the testcase. There was no reason why the setup behaves that way., (*4)
The only workaround was to introduce a ignore tag called ignore-js-error
. Scenarios with that tag will not be checked
in any way., (*5)
Just install via composer, (*6)
Add the context to your behat confguration file. There are no Constructor Parameters, (*7)
You need to adjust your application to work with the context., (*8)
Depending if you are using a javascript framework you might to adjust to that as well, (*9)
If you are using angular you might want to add your own exception handler to catch js errors., (*10)
"use strict"; !function (angular) { var Module = angular.module('myModule'); Module.provider("$exceptionHandler", { $get: ['errorLogService', function (errorLogService) { return (errorLogService); }] } ); // // Factory to provider error log service // - simple console logger // Module.factory( "errorLogService", ['$log', function ($log) { function log(exception, cause) { // Default behavior, log to browser console $log.error.apply($log, arguments); // for selenium exception.message += ' (caused by "' + cause + '")'; if ($window.jsErrors !== undefined) { $window.jsErrors[$window.jsErrors.length] = exception.message; } } // Return the logging function. return (log); }] ); }(angular);
You don't need to adjust anything in your Scenarios to get this working. But there is way if you don't want the Context
to run at a specific Scenario or a whole Feature File. You can use the tag @ignore-js-logging
if you don't want any
step to check for js errors., (*11)