加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 06:57:57 所属栏目:安全 来源:网络整理
导读:我正在尝试使用以下配置在bitbucket平台上运行测试: image: node:6.8.0pipelines: 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
我正在尝试使用以下配置在bitbucket平台上运行测试:

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.

问题是业力无法启动Chrome浏览器.我认为任何码头环境都会出现问题.
如何在bitbucket管道中运行测试?

解决方法

尝试将测试切换到PhantomJS.

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

$npm install –save-dev karma-phantomjs-launcher

编辑你的karma.conf.js以使用PhantomJS

// /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
    },//...
  });
};

现在应该在PhantomJS而不是Chrome中运行测试.

默认测试脚本也运行watch,因此您可能希望将package.json测试脚本修改为“test”:“ng test –watch = false”.如果你想让本地开发运行,只需使用ng test而不是npm test启动.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读