Bitbucket - 您的平台上没有适用于 Chrome 浏览器的二进制文件

nig*_*are 4 bitbucket karma-runner reactjs bitbucket-pipelines

我正在研究基本的 React 项目,我可以在我的 mac 上使用 chrome 运行 karma 和 mocha 测试。但是 bitbucket pipeline 说我没有 chrome,所以问题是如何在那里安装 chrome,我每次构建时都必须安装它吗?

我的yml

image: node:7.10.0
    pipelines:
      default:
        - step:
            script:
              - npm install -g bower
              - bower install --allow-root
              - npm install
              - npm test
Run Code Online (Sandbox Code Playgroud)

karma.conf.js

module.exports = function(config) {
config.set({
    basePath: '',
    frameworks: ['mocha'],
    files: [
        './tests/*.js'
    ],
    exclude: [],
    preprocessors: {
        './tests/*.js': ['webpack']
    },
    // webpack configuration
    webpack: require('./webpack.dev.js'),
    webpackMiddleware: {
        stats: 'errors-only'
    },
    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'], //run in Chrome
    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true,
    concurrency: Infinity
});
Run Code Online (Sandbox Code Playgroud)

};

Blu*_*ueM 5

image: node:7.10.0你的行bitbucket-pipelines.yml指定要使用的 Docker 映像。在你的例子中,它\xe2\x80\x99是一个普通的节点版本7.10.0图像,因此其中不包含Chrome。

\n\n

您可以做两件事:

\n\n
    \n
  • 了解 Docker,了解如何创建自己的包含 Chrome(或任何其他软件)的映像,然后在管道中使用该映像
  • \n
  • 或者,可能更简单:搜索由其他人创建的现有 Docker 映像,其中包括节点、Chrome 以及您可能需要的其他软件。然后,在image: <image-name>配置行中使用该图像。
  • \n
\n\n

无论哪种情况,一旦您拥有合适的映像,运行管道时都将需要它,并且 Chrome 将立即可用,并且您将不需要任何类型的 \xe2\x80\x9cinstallation\xe2\x80\x9d。

\n

  • 作为奖励,如果所有工具都已在映像中,那么您无需花费构建时间来获取或安装它们。 (2认同)