rastasheep / alpine-node-chromium

Dockerized chromium inside node alpine image
MIT License
37 stars 22 forks source link

Cannot load browser "ChromiumNoSandbox": it is not registered! Perhaps you are missing some plugin? #12

Open NicolaSpreafico opened 4 years ago

NicolaSpreafico commented 4 years ago

Hello, we are creating a pipeline for a node project.

Our goal is obtain the lcov.info file (which will later read by SonarQube) with the command

ng test --code-coverage

From our local machine is working fine, so I consider the project itself correctly configured.

This is our karma configuration (as written in the documentation we added the browser definition)

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')
    ],
    client: {
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, '../coverage'),
      reports: ['html', 'lcovonly', 'text-summary'],
      fixWebpackSourcePaths: true
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ["ChromiumNoSandbox"],
    //browsers: ["ChromeHeadless"],
    customLauchers: {
      ChromiumNoSandbox: {
        base: 'ChromiumHeadless',
        flags: ['--no-sandbox', '--headless', '--disable-gpu', '--disable-translate', '--disable-extensions']
      }
    },
    singleRun: false
  });
};

This is our docker image:

FROM rastasheep/alpine-node-chromium:10-alpine
ARG ng_version=latest
RUN npm install -g @angular/cli@$ng_version --unsafe-perms && \
    ng version
ENTRYPOINT ["ng"]

We started from this image and we added the ng command line which will be used from our project.

When the pipeline is running and the image is loaded, we are getting this error:

Step #2 - "NG Test Code Coverage": 10 07 2020 08:09:24.662:WARN [karma]: No captured browser, open http://localhost:9876/
Step #2 - "NG Test Code Coverage": 10 07 2020 08:09:24.734:INFO [karma-server]: Karma v4.1.0 server started at http://0.0.0.0:9876/
Step #2 - "NG Test Code Coverage": 10 07 2020 08:09:24.735:INFO [launcher]: Launching browsers ChromiumNoSandbox with concurrency unlimited
Step #2 - "NG Test Code Coverage": 10 07 2020 08:09:24.736:ERROR [launcher]: Cannot load browser "ChromiumNoSandbox": it is not registered! Perhaps you are missing some plugin?
Step #2 - "NG Test Code Coverage": 10 07 2020 08:09:24.737:ERROR [karma-server]: Error: Found 1 load error
Step #2 - "NG Test Code Coverage":     at Server.<anonymous> (/workspace/node_modules/karma/lib/server.js:182:27)
Step #2 - "NG Test Code Coverage":     at Object.onceWrapper (events.js:299:28)
Step #2 - "NG Test Code Coverage":     at Server.emit (events.js:215:7)
Step #2 - "NG Test Code Coverage":     at emitListeningNT (net.js:1335:10)
Step #2 - "NG Test Code Coverage":     at processTicksAndRejections (internal/process/task_queues.js:79:21)

This is the error:

Cannot load browser "ChromiumNoSandbox": it is not registered! Perhaps you are missing some plugin?

We completed the Karma configuration with the example we found on this repository README, and it should work. Do you have any suggestion on what is missing from our configuration?

rastasheep commented 4 years ago

@NicolaSpreafico Have you checked this issue https://github.com/karma-runner/karma-chrome-launcher/issues/165 ?

NicolaSpreafico commented 4 years ago

@rastasheep Unfortunately the issue you linked was solved by updating karma-chrome-launcher to the version 2.2.0 We are already using that version but we're still having this issue.

      "karma": "~4.1.0",
        "karma-chrome-launcher": "~2.2.0",
        "karma-coverage-istanbul-reporter": "~2.0.1",
        "karma-jasmine": "~2.0.1",
        "karma-jasmine-html-reporter": "^1.4.0",
rastasheep commented 4 years ago

Hmm its really hard to debug it without working example, can you try to create minimal setup than can reproduce issue?

On Fri, Jul 10, 2020, 12:47 NicolaSpreafico notifications@github.com wrote:

@rastasheep https://github.com/rastasheep Unfortunately the issue you linked was solved by updating karma-chrome-launcher to the version 2.2.0 We are already using that version but we're still having this issue.

  "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rastasheep/alpine-node-chromium/issues/12#issuecomment-656612294, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFJ33UYALM2W6G3VH74JCLR23WVBANCNFSM4OWLQ4OQ .