【问题标题】:ng e2e on TeamCity only @angular/cli script that doesn't workng e2e on TeamCity 只有 @angular/cli 脚本不起作用
【发布时间】:2023-03-28 11:00:01
【问题描述】:

我正在使用 TeamCity 10 并尝试获取 @angular/cli 项目以在构建步骤中执行以下操作: e2e 脚本之前,一切都运行良好。它会停止构建,我必须强制关闭它。

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

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

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

【问题讨论】:

    标签: angular npm continuous-integration teamcity angular-cli


    【解决方案1】:

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

    【讨论】:

    • 举个例子就好了!你能帮我理解一些事情吗?我不确定我是否理解为什么ng e2e 在我的一个构建代理上的工作方式与在本地的工作方式不同?我可以通过远程桌面连接登录到这些构建代理。当 TeamCity 在其中一个代理上开始构建时,我是否能够使它与桌面交互?我们有另一个项目通过 TeamCity 在 WinForms 项目上运行 Coded UI 测试。我只是不确定它是如何组合在一起的。有没有办法通过真正的浏览器运行这些?
    • 构建代理作为 Windows 服务运行,服务通常无法启动与桌面(IE.Chrome)的交互进程,这就是为什么您必须使用 PhantomJS 来运行您的 E2E 测试。
    • 嘿本,你还有那个例子吗?
    猜你喜欢
    • 1970-01-01
    • 2018-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多