npm run e2e throws an UnhandledPromiseRejectionWarning
Spinnenzunge opened this issue · 2 comments
Starter Type: angular
Starter Template: tabs
Description:
Running e2e tests on a new angular tabs ionic project throws an UnhandledPromiseRejectionWarning (see stacktrace on bottom of the issue). The e2e test completes successfully.
My ionic info
:
Ionic:
Ionic CLI : 6.12.4 (/Users/pascalgraf/.nvm/versions/node/v14.7.0/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.5.4
@angular-devkit/build-angular : 0.1100.7
@angular-devkit/schematics : 11.0.7
@angular/cli : 11.0.7
@ionic/angular-toolkit : 2.3.3
Capacitor:
Capacitor CLI : 2.4.6
@capacitor/core : 2.4.6
Utility:
cordova-res (update available: 0.15.3) : 0.15.2
native-run (update available: 1.3.0) : 1.2.2
System:
NodeJS : v14.7.0 (/Users/pascalgraf/.nvm/versions/node/v14.7.0/bin/node)
npm : 6.14.7
OS : macOS Catalina
Other Information:
> ng e2e
[13:05:51] I/update - chromedriver: file exists /Users/pascalgraf/Workspaces/map-core-b2c-app/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_88.0.4324.96.zip
[13:05:51] I/update - chromedriver: unzipping chromedriver_88.0.4324.96.zip
[13:05:51] I/update - chromedriver: setting permissions to 0755 for /Users/pascalgraf/Workspaces/map-core-b2c-app/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_88.0.4324.96
[13:05:51] I/update - chromedriver: chromedriver_88.0.4324.96 up to date
✔ Browser application bundle generation complete.
Initial Chunk Files | Names | Size
vendor.js | vendor | 4.44 MB
polyfills.js | polyfills | 251.55 kB
styles.css | styles | 30.78 kB
main.js | main | 13.07 kB
runtime.js | runtime | 9.64 kB
| Initial Total | 4.74 MB
Lazy Chunk Files | Names | Size
swiper-bundle-95afeea2-js.js | swiper-bundle-95afeea2-js | 200.07 kB
polyfills-core-js.js | polyfills-core-js | 92.39 kB
11.js | - | 72.58 kB
17.js | - | 71.93 kB
2.js | - | 63.09 kB
33.js | - | 56.15 kB
1.js | - | 47.59 kB
26.js | - | 46.98 kB
31.js | - | 37.12 kB
21.js | - | 32.50 kB
6.js | - | 32.35 kB
19.js | - | 32.15 kB
30.js | - | 31.73 kB
16.js | - | 30.85 kB
0.js | - | 29.81 kB
20.js | - | 26.68 kB
12.js | - | 26.41 kB
25.js | - | 26.28 kB
32.js | - | 24.53 kB
36.js | - | 23.93 kB
29.js | - | 23.69 kB
40.js | - | 21.74 kB
23.js | - | 21.13 kB
22.js | - | 21.05 kB
polyfills-dom.js | polyfills-dom | 19.47 kB
15.js | - | 19.39 kB
common.js | common | 19.35 kB
42.js | - | 17.78 kB
39.js | - | 17.33 kB
41.js | - | 16.95 kB
7.js | - | 15.95 kB
shadow-css-58508bb5-js.js | shadow-css-58508bb5-js | 15.82 kB
4.js | - | 15.77 kB
24.js | - | 15.70 kB
10.js | - | 15.70 kB
input-shims-7a52f98d-js.js | input-shims-7a52f98d-js | 15.37 kB
18.js | - | 15.10 kB
14.js | - | 12.96 kB
27.js | - | 12.03 kB
8.js | - | 11.43 kB
polyfills-css-shim.js | polyfills-css-shim | 10.67 kB
9.js | - | 9.73 kB
35.js | - | 9.28 kB
34.js | - | 7.85 kB
37.js | - | 7.67 kB
tabs-tabs-module.js | tabs-tabs-module | 7.45 kB
tab3-tab3-module.js | tab3-tab3-module | 6.83 kB
tab1-tab1-module.js | tab1-tab1-module | 6.54 kB
tab2-tab2-module.js | tab2-tab2-module | 6.54 kB
28.js | - | 5.98 kB
keyboard-5742b5da-js.js | keyboard-5742b5da-js | 5.97 kB
3.js | - | 5.88 kB
tap-click-71d2324a-js.js | tap-click-71d2324a-js | 5.53 kB
5.js | - | 3.33 kB
13.js | - | 3.24 kB
swipe-back-2154c9a7-js.js | swipe-back-2154c9a7-js | 2.69 kB
focus-visible-f4ad4f1a-js.js | focus-visible-f4ad4f1a-js | 1.92 kB
38.js | - | 1.64 kB
status-tap-b46a1b02-js.js | status-tap-b46a1b02-js | 1.41 kB
Build at: 2021-02-09T12:06:01.860Z - Hash: 457fddeb699c189cb39d - Time: 7945ms
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
✔ Compiled successfully.
[13:06:02] I/launcher - Running 1 instances of WebDriver
[13:06:02] I/direct - Using ChromeDriver directly...
Jasmine started
new App
✓ should display welcome message
Executed 1 of 1 spec SUCCESS in 0.007 sec.
(node:17546) UnhandledPromiseRejectionWarning: Error: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
at /Users/pascalgraf/Workspaces/map-core-b2c-app/node_modules/protractor/built/browser.js:461:23
at processTicksAndRejections (internal/process/task_queues.js:93:5)Error:
at ElementArrayFinder.applyAction_ (/Users/pascalgraf/Workspaces/map-core-b2c-app/node_modules/protractor/built/element.js:459:27)
at ElementArrayFinder.<computed> [as getText] (/Users/pascalgraf/Workspaces/map-core-b2c-app/node_modules/protractor/built/element.js:91:29)
at ElementFinder.<computed> [as getText] (/Users/pascalgraf/Workspaces/map-core-b2c-app/node_modules/protractor/built/element.js:831:22)
at AppPage.getPageTitle (/Users/pascalgraf/Workspaces/map-core-b2c-app/e2e/src/app.po.ts:9:41)
at UserContext.<anonymous> (/Users/pascalgraf/Workspaces/map-core-b2c-app/e2e/src/app.e2e-spec.ts:12:17)
at /Users/pascalgraf/Workspaces/map-core-b2c-app/node_modules/jasminewd2/index.js:112:25
at new Promise (<anonymous>)
at SimpleScheduler.promise (/Users/pascalgraf/Workspaces/map-core-b2c-app/node_modules/selenium-webdriver/lib/promise.js:2242:12)
at schedulerExecute (/Users/pascalgraf/Workspaces/map-core-b2c-app/node_modules/jasminewd2/index.js:95:18)
at /Users/pascalgraf/Workspaces/map-core-b2c-app/node_modules/selenium-webdriver/lib/promise.js:2232:22
(Use `node --trace-warnings ...` to show where the warning was created)
(node:17546) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:17546) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[13:06:04] I/launcher - 0 instance(s) of WebDriver still running
[13:06:04] I/launcher - chrome #01 passed
Just an update, I found out the problem was that the e2e test did not wait for the async methods of the PageObject.
Fixed it by making my unit test block async and waiting for the page.navigateTo()
and page.getPageTitle()
events.
it('should display welcome message', async () => {
await page.navigateTo();
expect(await page.getPageTitle()).toContain('Overview');
});
Maybe this can be updated in the Ionic starter templates, I believe the Angular starter contains the async/await pattern in their starters.
Hey there,
Apologies for the delay. The tabs applications do not have this test anymore, so I am going to close this.