There are problems by protractor in case you have some long timeouts or intervals in your app.
Protractor will wait forever in such case.
This plugin let you setup ignore rules for some long async calls.
-
install the plugin
npm i protractor-sync-options-plugin -D
-
for now, you should add
import 'zone.js/dist/task-tracking.js';
to your
polyfills.ts
file right afterimport 'zone.js/dist/zone';
line.
(see github issues, help me to fix it) -
in your
protractor.js
file add plugins definition:exports.config = { plugins: [ { package: 'protractor-sync-options-plugin', ignoreTasks: [<filter1>, <filter2> ..], } ], ...
the filters are of type IgnoreTask
exports.config = {
plugins: [
{
package: 'protractor-sync-options-plugin',
ignoreTasks: [
{creationLocation: 'lodash'},
{source: 'setInterval', creationLocation: 'MyComponent.checkEveryTime'},
{source: 'XMLHttpRequest.send'}
],
}
],
{creationLocation: 'lodash'}
: filters every promise, observable, setTimeout, setInterval etc. from any code fromlodash
library{source: 'setInterval', creationLocation: 'MyComponent.checkEveryTime'}
: filters onlysetTinterval
calls fromMyComponent
'scheckEveryTime
method{source: 'XMLHttpRequest.send'}
: filters all XHR requests
All 3 filters will be applied after each other, if any filter matches the current waiting task of protractor, the task will be ignored, and protractor would continue.
see also protractor.js file
The filter objects in the ignoreTasks
array are applied over "OR" (disjunction)
The filter properties of one single element (creationLocation and source) are applied over "AND" (conjunction)
- setTimeout
- setInterval
- setImmediate
- XMLHttpRequest.send
- requestAnimationFrame
- webkitRequestAnimationFrame
- mozRequestAnimationFrame
got from angular/packages/zone.js/lib/zone-spec/fake-async-test.ts
promises and observables uses setTimeout
/setInterval
in most cases.
Each task in zone.js has location simple by error.stacktrace of the called place.
The plugin searches through all function calls of the async task, and try to match the defined in this property string/regex.
So, be careful with this setting, since it can match too much.
(for example you want to filter some library with name: 'time', and you have some method that has 'time' in its name, so the method's async calls will be filtered too)
Feel free to make a PRs / create an issue!