How to track which async tasks protractor is waiting on?

后端 未结 4 1788
孤城傲影
孤城傲影 2021-01-31 04:39

I have a medium sized Angular application and for some reasons some of my protractor tests are timing out when run against my live production environment.

I am fairly sur

4条回答
  •  孤城傲影
    2021-01-31 04:49

    berkov,

    I really need your help to get task list using the functionality provided by you.

    I added import 'zone.js/dist/task-tracking'; to polyfills.ts and below code to constructor method of AppModule.ts. but it is throwing error Cannot find name 'moduleInstance'.

    // app.module.ts
    
    const ngZone = moduleInstance.injector.get(NgZone);
    setInterval(() => {
        var taskTrackingZone = (ngZone)._inner.getZoneWith("TaskTrackingZone");
        if (!taskTrackingZone) {
            throw new Error("'TaskTrackingZone' zone not found! Have you loaded 'node_modules/zone.js/dist/task-tracking.js'?");
        }
        var tasks: any[] = taskTrackingZone._properties.TaskTrackingZone.getTasksFor("macroTask");
        tasks = _.clone(tasks);
        if (_.size(tasks) > 0) {
            console.log("ZONE pending tasks=", tasks);
        }
    }, 1000);
    

    If it is possible, can you please provide any working example. That will be your great help.

    Thank you,

    Jignesh Raval

    CC: @hodossy-szabolcs

提交回复
热议问题