protractor-sync-options-plugin v1.0.0-alpha.5
Why?
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.
Setup
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
Usage example
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 some code fromlodash
library{source: 'setInterval', creationLocation: 'MyComponent.checkEveryTime'}
filters onlysetTinterval
calls fromMyComponent
'scheckEveryTime
method{source: 'XMLHttpRequest.send'}
filters all XHR requests
see also protractor.js file
'API' Description
The filter objects in the ignoreTasks
array are joined over "OR" (disjunction)
The filter properties of one single element (creationLocation and source) are joined over "AND" (conjunction)
source
option (task types):
- 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.
creationLocation
option
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)
Contribution
Feel free to make a PRs / create an issue!
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago