ng e2e on TeamCity only @angular/cli script that doesn't work

痴心易碎 提交于 2019-12-11 08:03:35

问题


I'm using TeamCity 10 and trying to get an @angular/cli project to do the following in a build step: Everything runs fine until the e2e script. It halts the build and I have to force shut it down.

So I logged onto my build agent remotely and tried running the command ng e2e myself in the location of the code it just pulled, and I get a chrome browser window to come up, but within 10 seconds it crashes with the following errors:

PS C:\TeamCity\BuildAgent\work\4038db2ebec7f79b> npm run e2e

> tdportal@0.0.0 e2e C:\TeamCity\BuildAgent\work\4038db2ebec7f79b
> ng e2e

** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152 **
(node:5660) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
Hash: 4e69738611fdf13a3b2b
Time: 24258ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 158 kB {5} [initial] [rendered]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 70.9 kB {4} [initial] [rendered]
chunk    {2} scripts.bundle.js, scripts.bundle.js.map (scripts) 910 kB {5} [initial] [rendered]
chunk    {3} styles.bundle.js, styles.bundle.js.map (styles) 420 kB {5} [initial] [rendered]
chunk    {4} vendor.bundle.js, vendor.bundle.js.map (vendor) 4.32 MB [initial] [rendered]
chunk    {5} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
webpack: Compiled successfully.
[14:40:49] I/update - chromedriver: file exists C:\TeamCity\BuildAgent\work\4038db2ebec7f79b\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.29.zip
[14:40:49] I/update - chromedriver: unzipping chromedriver_2.29.zip
[14:40:50] I/update - chromedriver: chromedriver_2.29.exe up to date
[14:40:50] I/launcher - Running 1 instances of WebDriver
[14:40:50] I/direct - Using ChromeDriver directly...
Spec started
[14:41:07] E/protractor - Could not find Angular on page http://localhost:49152/ : retries looking for angular exceeded

  tdportal App
    × should display message saying Team Digital Portal
      - Failed: Angular could not be found on the page http://localhost:49152/.If this is not an Angular application, you may need to turn off waiting for Angular.
            Please see https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load
            Please see https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load
      at executeAsyncScript_.then (C:\TeamCity\BuildAgent\work\4038db2ebec7f79b\node_modules\protractor\lib\browser.ts:936:29)
      at ManagedPromise.invokeCallback_ (C:\TeamCity\BuildAgent\work\4038db2ebec7f79b\node_modules\selenium-webdriver\lib\promise.js:1366:14)
      at TaskQueue.execute_ (C:\TeamCity\BuildAgent\work\4038db2ebec7f79b\node_modules\selenium-webdriver\lib\promise.js:2970:14)
      at TaskQueue.executeNext_ (C:\TeamCity\BuildAgent\work\4038db2ebec7f79b\node_modules\selenium-webdriver\lib\promise.js:2953:27)
      at asyncRun (C:\TeamCity\BuildAgent\work\4038db2ebec7f79b\node_modules\selenium-webdriver\lib\promise.js:2813:27)
      at C:\TeamCity\BuildAgent\work\4038db2ebec7f79b\node_modules\selenium-webdriver\lib\promise.js:676:7
      at process._tickCallback (internal/process/next_tick.js:109:7)
  From: Task: Run it("should display message saying Team Digital Portal") in control flow
      at ControlFlow.emit (C:\TeamCity\BuildAgent\work\4038db2ebec7f79b\node_modules\selenium-webdriver\lib\events.js:62:21)
      at ControlFlow.shutdown_ (C:\TeamCity\BuildAgent\work\4038db2ebec7f79b\node_modules\selenium-webdriver\lib\promise.js:2565:10)
      at shutdownTask_.MicroTask (C:\TeamCity\BuildAgent\work\4038db2ebec7f79b\node_modules\selenium-webdriver\lib\promise.js:2490:53)
      at MicroTask.asyncRun (C:\TeamCity\BuildAgent\work\4038db2ebec7f79b\node_modules\selenium-webdriver\lib\promise.js:2619:9)
      at C:\TeamCity\BuildAgent\work\4038db2ebec7f79b\node_modules\selenium-webdriver\lib\promise.js:676:7
      at process._tickCallback (internal/process/next_tick.js:109:7)
  From asynchronous test:
  Error
      at Suite.<anonymous> (C:\TeamCity\BuildAgent\work\4038db2ebec7f79b\e2e\app.e2e-spec.ts:10:3)
      at Object.<anonymous> (C:\TeamCity\BuildAgent\work\4038db2ebec7f79b\e2e\app.e2e-spec.ts:3:1)
      at Module._compile (module.js:571:32)
      at Module.m._compile (C:\TeamCity\BuildAgent\work\4038db2ebec7f79b\node_modules\ts-node\src\index.ts:406:23)
      at Module._extensions..js (module.js:580:10)
      at Object.require.extensions.(anonymous function) [as .ts] (C:\TeamCity\BuildAgent\work\4038db2ebec7f79b\node_modules\ts-node\src\index.ts:409:12)
      at Module.load (module.js:488:32)
      at tryModuleLoad (module.js:447:12)
      at Function.Module._load (module.js:439:3)
      at Module.require (module.js:498:17)
      at require (internal/module.js:20:19)

**************************************************
*                    Failures                    *
**************************************************

1) tdportal App should display message saying Team Digital Portal
  - Failed: Angular could not be found on the page http://localhost:49152/.If this is not an Angular application, you may need to turn off waiting for Angular.
                        Please see
                        https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load

Executed 1 of 1 spec (1 FAILED) in 13 secs.
[14:41:07] I/launcher - 0 instance(s) of WebDriver still running
[14:41:07] I/launcher - chrome #01 failed 1 test(s)
[14:41:07] I/launcher - overall: 1 failed spec(s)
[14:41:07] E/launcher - Process exited with error code 1

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "e2e"
npm ERR! node v7.10.0
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tdportal@0.0.0 e2e: `ng e2e`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tdportal@0.0.0 e2e script 'ng e2e'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the tdportal package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ng e2e
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs tdportal
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls tdportal
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\J.Smith\AppData\Roaming\npm-cache\_logs\2017-05-24T20_41_07_438Z-debug.log

Why can't I run my e2e tests on this machine if everything else works? What do I need to do differently?


回答1:


The E2E tests require Chrome being launched on the TeamCity agent in order to run the tests, and since the agent is running without interacting with the desktop, you can't run your E2E tests with Chrome. Instead, you need to configure Karma to run your E2E tests with PhantomJs. Phantom is a headless browser and works without having to interact with the desktop. Let me know if you need an example, I have to dig out mine.



来源:https://stackoverflow.com/questions/44168390/ng-e2e-on-teamcity-only-angular-cli-script-that-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!