本文介绍了TeamCity 上的 ng e2e 仅 @angular/cli 脚本不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 TeamCity 10 并尝试让 @angular/cli 项目在构建步骤中执行以下操作:一切正常,直到 e2e 脚本.它会停止构建,我必须强制关闭它.

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.

所以我远程登录到我的构建代理并尝试在它刚刚提取的代码所在的位置自己运行命令 ng e2e,然后我得到了一个 chrome 浏览器窗口,但在 10 之内秒它崩溃并出现以下错误:

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

> [email protected] 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! [email protected] e2e: `ng e2e`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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

如果其他一切正常,为什么我不能在这台机器上运行我的 e2e 测试?我需要做什么不同的事情?

推荐答案

E2E 测试需要在 TeamCity 代理上启动 Chrome 才能运行测试,并且由于代理在运行时不与桌面交互,因此您可以't 使用 Chrome 运行您的 E2E 测试.相反,您需要配置 Karma 以使用 PhantomJs 运行您的 E2E 测试.Phantom 是一款无头浏览器,无需与桌面交互即可工作.如果您需要示例,请告诉我,我必须挖掘出我的示例.

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.

这篇关于TeamCity 上的 ng e2e 仅 @angular/cli 脚本不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 07:27