Can't run unit test using karma in Teamcity build. Error: 'Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.'

Viewed 207

I trying to run karma tests on teamcity and encounter such error:

npm ERR! ERROR: Failed to set up Chromium r901912! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.

my configurations:

package.json:

"test-ci": "ng test --configuration=ci"

angular.json > projects > architect:

"test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "karmaConfig": "./karma.conf.js",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "scripts": [],
            "styles": [
              "src/styles.scss"
            ],
            "assets": [
              "src/assets",
              "src/favicon.ico"
            ]
          },
          "configurations": {
            "ci": {
              "karmaConfig": "./karma.conf.ci.js"
            }
          }
        }

karma.conf.ci.js:

const puppeteer = require('puppeteer');
process.env.CHROME_BIN = puppeteer.executablePath();

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular-devkit/build-angular/plugins/karma'),
      require('karma-teamcity-reporter')
    ],
    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    files: [],
    preprocessors: {},
    mime: {
      'text/x-typescript': ['ts','tsx']
    },
    reporters: ["teamcity", "coverage-istanbul"],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    singleRun: true,
    customLaunchers: {
      ChromeCustom: {
        base: 'ChromeHeadless',
        flags: '--no-sandbox'
      }
    },
    codeCoverage: true,
    watch: false,
  });
};

Build step custom script:

npm run test-ci

Basically the question is in what place i can configure that variable. Sorry, i am a frontend developer and don't have expereince at front-ops at all, trying to figure it out, so my question might be dumb

0 Answers
Related