SAP / jenkins-library

Jenkins shared library for Continuous Delivery pipelines.
https://www.project-piper.io
Apache License 2.0
781 stars 594 forks source link

karmaExecuteTests.groovy: what should be the correct browser setting to call the KarmaExecuteTests? #4299

Closed EszterBalog closed 1 year ago

EszterBalog commented 1 year ago

We would like to execute automated tests with Karma. Our starting project is https://github.com/SAP/openui5-sample-app, which runs perfectly on local machine. We have tried to call the KarmaExecuteTest groovy script from out job in JAAS jenkins but get an: "No binary for ChromeHeadless browser on your platform. Set "CHROME_BIN" env variable" error. We tried it with headless chrome as well, but the same error comes up. Below I attached the respective log snippet from the job execution.

Chrome
13:34:36  warn  karmaExecuteTests - \[33m20 03 2023 12:34:36.771:WARN \[karma\]: \[39mNo captured browser, open http://localhost:9876/
13:34:36  info  karmaExecuteTests - \[32m20 03 2023 12:34:36.782:INFO \[karma-server\]: \[39mKarma v6.4.1 server started at http://localhost:9876/
13:34:36  info  karmaExecuteTests - \[32m20 03 2023 12:34:36.782:INFO \[launcher\]: \[39mLaunching browsers CustomChrome with concurrency unlimited
13:34:36  info  karmaExecuteTests - \[32m20 03 2023 12:34:36.785:INFO \[launcher\]: \[39mStarting browser Chrome
**13:34:36  error karmaExecuteTests - \[91m20 03 2023 12:34:36.786:ERROR \[launcher\]: \[39mNo binary for Chrome browser on your platform.
13:34:36  info  karmaExecuteTests -   Please, set "CHROME_BIN" env variable.**

headless chrome
15:39:28  warn  karmaExecuteTests - \[33m17 03 2023 14:39:27.852:WARN \[karma\]: \[39mNo captured browser, open http://localhost:9876/
15:39:28  info  karmaExecuteTests - \[32m17 03 2023 14:39:27.863:INFO \[karma-server\]: \[39mKarma v6.4.1 server started at http://localhost:9876/
15:39:28  info  karmaExecuteTests - \[32m17 03 2023 14:39:27.863:INFO \[launcher\]: \[39mLaunching browsers CustomChromeHeadless with concurrency unlimited
15:39:28  info  karmaExecuteTests - \[32m17 03 2023 14:39:27.866:INFO \[launcher\]: \[39mStarting browser ChromeHeadless
**15:39:28  error karmaExecuteTests - \[91m17 03 2023 14:39:27.867:ERROR \[launcher\]: \[39mNo binary for ChromeHeadless browser on your platform.**
**15:39:28  info  karmaExecuteTests -   Please, set "CHROME_BIN" env variable.**

We have created a copy of this project in our organization. The branch main contains the original code. Here is the groovy script we use in case of running the job with the openui5-sample-app's code.

@Library(['piper-lib-os']) _

pipeline{
  agent any
  stages{
    stage('Tests'){
      steps{
        git credentialsId:'GITHUB_USER', url:'https://github.tools.sap/IBP-CTAT/openui5-sample-app.git', changelog: false, poll: false, branch: params.GitBranch
        **karmaExecuteTests(script: this)**
        archiveArtifacts '**/target/**'
      }
    }
  }
}
Could you please help us how to set the browser settings properly or a working example would be also high appreciated?

Thank you, best regards Eszter

CCFenner commented 1 year ago

As you refer to JAAS I assume you have also access this package which does all the necessary configuration:

npm install --save-dev @sap/piper-karma-config

EszterBalog commented 1 year ago

@CCFenner Hi Christopher,

Thank you very much for your hint. Unfortunately I'm new to this npm topic, so I would need some help again. I’ve tried to use the npm install --save-dev @sap/piper-karma-config but I get this error when the npm is trying to install the @sap/piper-karma-config:

11:46:31 error karmaExecuteTests - npm ERR! code E404 
11:46:31 error karmaExecuteTests - npm ERR! 404 Not Found - GET https://int.repositories.cloud.sap/artifactory/proxy-deploy-releases-hyperspace-npm/-/@sap%2fpiper-karma-config 
11:46:31 error karmaExecuteTests - npm ERR! 404 
11:46:31 error karmaExecuteTests - npm ERR! 404 '@sap/piper-karma-config@0.11.3' is not in this registry. 
11:46:31 error karmaExecuteTests - npm ERR! 404

Could you help me what should be the right link for this dependency? In the browser I can find the dependency here: https://int.repositories.cloud.sap/artifactory/proxy-deploy-releases-hyperspace-npm/%40sap/ I’ve also added the @sap/piper-karma-config to my package.json file: https://github.tools.sap/IBP-CTAT/openui5-sample-app/blob/karmaInstall/package.json

I’m trying to run this project in JAAS: https://github.tools.sap/IBP-CTAT/openui5-sample-app.git

I’ve created a .npmrc file also to override the default registry settings: https://github.tools.sap/IBP-CTAT/openui5-sample-app/blob/karmaInstall/.npmrc

The install.sh contains the npm commands which I run in the groovy script of the Jenkins job: https://github.tools.sap/IBP-CTAT/openui5-sample-app/blob/karmaInstall/install.sh The groovy script code is:

@Library(['piper-lib','piper-lib-os']) _

pipeline{
  agent any
  stages{
    stage('Tests'){
      steps{
        git credentialsId:'GITHUB_USER', url:'https://github.tools.sap/IBP-CTAT/openui5-sample-app.git', changelog: false, poll: false, branch: params.GitBranch
        karmaExecuteTests(script: this,
                          sidecarImage: 'selenium/standalone-chrome:latest',
                          installCommand:'bash install.sh'
        )
        archiveArtifacts '**/target/**'
      }
    }
  }
}

Thanks in advance for your help! Best regards, Eszter

github-actions[bot] commented 1 year ago

Thank you for your contribution! This issue is stale because it has been open 60 days with no activity. In order to keep it open, please remove stale label or add a comment within the next 10 days. If you need a Piper team member to remove the stale label make sure to add @SAP/jenkins-library-team to your comment.

github-actions[bot] commented 1 year ago

Issue got stale and no further activity happened. It has automatically been closed. Please re-open in case you still consider it relevant.