akveo / ngx-admin

Customizable admin dashboard template based on Angular 10+
https://akveo.github.io/ngx-admin/
MIT License
25.29k stars 7.96k forks source link

ngx-admin does not work with protractor #1647

Open rburgst opened 6 years ago

rburgst commented 6 years ago

Issue type

I'm submitting a ...

Issue description

Current behavior: Its currently impossible to write stable protractor tests since ngx-admin seems to do some things under the hood that prevent protractor from finding out whether angular has settled or not.

If you run

ng e2e

on the following fork

https://github.com/rburgst/ngx-admin/commit/d077b2563a10550109081d9e8522d204ebde2367

you will get the following error

1) protractor-problem App should display welcome message
  - ScriptTimeoutError: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular
  While waiting for element with locator - Locator: By(css selector, .user-name)

This happens after a trivial 2 step spec:

    await browser.get('/');
    expect(element(by.css('.user-name')).getText()).toEqual('Nick Jones');

My real app is somewhat more involved but I am getting the same kinds of issues. Since the very same test works fine with a vanilla angular app, I am inclined to believe that ngx-admin or nebular has something to do with it.

Expected behavior: It should be possible to write robust protractor tests that dont timeout while waiting for angular.

Steps to reproduce:

Check out the following commit / repo

https://github.com/rburgst/ngx-admin/commit/d077b2563a10550109081d9e8522d204ebde2367

Related code:

https://github.com/rburgst/ngx-admin

    await browser.get('/');
    expect(element(by.css('.user-name')).getText()).toEqual('Nick Jones');

Other information:

npm, node, OS, Browser

Node, npm: `node --version` and `npm --version`
node --version
> v9.5.0
yarn --version
> 1.6.0
OS: macOS (High Sierra)
Browser: Chrome

Angular, Nebular

same as on master: SHA1 bb9dccf 
nnixaa commented 6 years ago

Hey @rburgst, thanks for reporting. I played a bit with your example and it turns out its pace-js who's blocking angular to complete so that the tests could start. A solution here would be to run it out of angular zone, but I need to look into how can we do this for a 3rd party library that run's automatically. In the mean time you can use browser.waitForAngularEnabled(false); or remove pace-js from .angular-cli.json file.

rburgst commented 6 years ago

Hm, I can verify with the vanilla ngx-admin project it works now after removing pace.js from .angular-cli.json, however, my real project is based on ngx-admin, it still shows the same behaviour. How do you debug this and see who is still responsible for the timeout?

nnixaa commented 6 years ago

To be honest, I just guessed, as there are a lot of setTimeout calls inside of the pace-js source code. You can try a similar way or just by removing code parts and libraries until it works - not the best suggestion but might work :)