cancel
Showing results for 
Search instead for 
Did you mean: 

Configure karmaExecuteTests in a Piper monorepo

andrea-stefani
Employee
Employee
0 Kudos
100

Hello Community! In my team we are moving our backend and frontend into a monorepo. We had karmaExecuteTests in our steps which was working fine with runCommand: 'npm run test:ci'. Now we are trying to run them in the frontend sub directory (runCommand: '(cd cxmc-onboarding-microfrontend && npm run test:ci)') but we always get an error message saying package.json does not exists. The directory and file exist, we can see them in Jenkins. Any Idea on what we do wrong? We have tried several ways like (runCommand: 'sh -c "cd cxmc-onboarding-microfrontend && npm run test:ci"') but they all get the same error. Thanks in advance!

Our karmaExecuteTests configuration before monorepo:

 

karmaExecuteTests:
  runCommand: 'npm run test:ci'
  sidecarImage: 'selenium/standalone-chrome:4.8'
  dockerImage: 'ppiper/node-browsers:20-bookworm'

 

Our karmaExecuteTests configuration in monorepo (giving package.json not found error) :

 

karmaExecuteTests:
  runCommand: '(cd cxmc-onboarding-microfrontend && npm run test:ci)'
  verbose: true
  sidecarImage: 'selenium/standalone-chrome:4.8'
  dockerImage: 'ppiper/node-browsers:20-bookworm' 

 

View Entire Topic
andrea-stefani
Employee
Employee
0 Kudos

Found a solution on the slack piper channel: https://sap-cx.slack.com/archives/C92KW1H55/p1718121474715759

Basically we added modules to point to the sub directory:

  karmaExecuteTests:
    dockerImage: "ppiper/node-browsers:20-bookworm"
    sidecarImage: "selenium/standalone-chrome:4.8"
    modules: [ "./cxmc-onboarding-microfrontend" ]
    runCommand: "npm run test:ci"