cancel
Showing results for 
Search instead for 
Did you mean: 

sap-fe-mockserver and karma, any example out there?

daniel_jakobs
Advisor
Advisor
0 Kudos
1,589

Hi colleagues,

I am developing fiori elements with odata v4. The fiori tooling generator creates nice test pages and the sap-fe-mockserver is much better then the old mockserver.

However when it comes to karma testing (local and in pipeline). I am a little bit lost.

Using karma-ui5 causes some problems.

The ui5.configPath ui5-local.yaml is not loading/mounting the sap-ui-core and more correctly. Karma server uses ./base/webapp/resources while fiori-tools-proxy listens to ./resources. I could add ../../../../ to all references but this looks weird. See https://answers.sap.com/questions/13665378/ui5-karma-config-404-on-ui5-resource-load.html

Does someone has a working example that uses own yaml with fiori-tools-proxy and sap-fe-mockserver?

Greetings and thanks,

Daniel

View Entire Topic
daniel_jakobs
Advisor
Advisor
0 Kudos

Well, after a night of try & error I found a solution that works for me.

in karma.conf.js I set the configPath to my own yaml especially for karma setup. Additionally I tweak a little bit to get my stuff covered by coverage reporter.

The ui5-karma.yaml:

Here it seems to be very important to listen to /base/... . So I do not need to adjust all sapui5 core in the html's references to ../../../../. I can just keep it as it is.

Finally it seems that own shortened resource roots are causing trouble and I did not want to face it yet. So I took the same resource root alias as in the main application. Typically the generator create a opa templat with a shortened one.

This setup runs OPA and QUnit

It also runs locally and on jenkins. We are using our own jenkins pipeline and trigger karma with this step

https://www.project-piper.io/steps/karmaExecuteTests/

Greetings,

Daniel