当前位置: 首页 > 知识库问答 >
问题:

Angular 2 cli在bitbucket管道上的运行测试

邓宜年
2023-03-14
image: node:6.8.0

pipelines:
  default:
    - step:
        script:
          - echo 'deb http://dl.google.com/linux/chrome/deb/ stable main' > /etc/apt/sources.list.d/chrome.list
          - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
          - set -x && apt-get update && apt-get install -y xvfb google-chrome-stable
          - ln -sf /usr/bin/xvfb-chrome /usr/bin/google-chrome
          - npm --version
          - npm install
          - npm test

这就是输出:

> ng test

Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
13 10 2016 15:26:57.937:WARN [karma]: No captured browser, open http://localhost:9876/

WARNING in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
45:15 Critical dependency: the request of a dependency is an expression

WARNING in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
57:15 Critical dependency: the request of a dependency is an expression
13 10 2016 15:26:57.945:INFO [karma]: Karma v1.2.0 server started at http://localhost:9876/
13 10 2016 15:26:57.946:INFO [launcher]: Launching browser Chrome with unlimited concurrency
13 10 2016 15:26:58.033:INFO [launcher]: Starting browser Chrome
13 10 2016 15:26:58.421:ERROR [launcher]: Cannot start Chrome

13 10 2016 15:26:58.532:INFO [launcher]: Trying to start Chrome again (1/2).
13 10 2016 15:26:58.813:ERROR [launcher]: Cannot start Chrome

13 10 2016 15:26:58.814:INFO [launcher]: Trying to start Chrome again (2/2).
13 10 2016 15:26:59.049:ERROR [launcher]: Cannot start Chrome

13 10 2016 15:26:59.050:ERROR [launcher]: Chrome failed 2 times (cannot start). Giving up.

问题是karma无法启动chrome浏览器。我认为这个问题会发生在任何码头工人的环境中。如何在bitbucket管道中运行测试?

共有1个答案

何雅惠
2023-03-14

尝试将测试切换到PhantomJS。

安装PhantomJS Runner https://github.com/karma-runner/karma-phantomjs-launcher

$npm安装--save-dev karma-phantomjs-launcher

// /karma.conf.js
module.exports = function (config) {
  config.set({
    // ...
    plugins: [
      // ...
      require('karma-phantomjs-launcher'),
      // ...  
    ],
    // ...  
    // browsers: ['Chrome'],
    browsers: ['PhantomJS'],
    phantomjsLauncher: {
      // Have phantomjs exit if a ResourceError is encountered 
      // (useful if karma exits without killing phantom)
      exitOnResourceError: true // Could require proxy if tests access images without /base path
    },
    //...
  });
};
 类似资料:
  • 我还试图将Docker映像添加到bitbucket-pipelines.yml文件中,希望能够直接在主机中而不是在容器中运行模拟器,但也不起作用,我从命令“adb devices”和“emulator-list-avds”中得到了空结果 有人知道什么可以帮助实现这个目标吗?我是说,在Bitbucket管道中运行Android上的自动化UI测试?

  • 问题内容: 在groovy脚本中(用于jenkins管道):如何运行命令而不是命令? 我尝试了以下方法: 在通话中致电“ ” : 将呼叫替换为呼叫: 附加信息: 我的命令比命令更复杂。 问题答案: 您提供的Groovy脚本正在将结果脚本中的第一行格式化为空白行。shebang告诉脚本使用/ bin / bash而不是/ bin / sh运行,它需要位于文件的第一行,否则它将被忽略。 因此,您应该这

  • 我试图在Beam管道完成后,在Google DataFlow上运行一个函数(或管道)。 目前,我已经构建了一个hack来运行该函数,方法是使用 ... func在哪里: 但是有更好的方法吗?

  • 我正在使用bitbucket管道,在一个步骤中,我想调用curl请求我们的API来将部署数据保存在DB中。 但是当我试图用BITBUCKET_BRANCH和BITBUCKET_REPO_SLUG变量调用curl时,它们总是为空或者根本没有填充。 这是我从管道中得到的回复。 你可以看到,对于分支dev1/*,我有第一步,我用两个变量调用curl。我尝试了两种使用我在互联网上找到的变量的方法,但都不起

  • 我已经编写了所有的e2e测试,它们在我的本地机器和代码上成功运行。我想把我们的CI从codeship移到Bitbucket管道。所以我用测试环境创建了自己的Docker映像。当我在本地工作区中运行docker conatiner时,测试工作正常,但当build在bitbucket管道中运行时,所有测试都因超时而失败,因为在页面上找不到angular。服务器肯定是在容器中启动和运行的ant测试也开始

  • 我试图建立持续集成(CI)在Bitbucket管道为Android。 我已经使用Android Studio 2.1.1创建了一个样例空白活动。 当运行时,会出现以下错误: 在工作目录中运行会得到: