SAP/karma-ui5

"QUnit not found" when using fiori-tools-proxy for proxying the ui5 sources

Siolto opened this issue · 1 comments

When I try to use the fiori-tools-proxy for loading the ui5 sources from a different location and I start and test the application locally, everything runs fine.

As soon as I try to run my tests with karma-ui5 I receive following error:

 Uncaught ReferenceError: QUnit is not defined
  at webapp/test/integration/opaTests.qunit.js:1:1

  ReferenceError: QUnit is not defined
      at webapp/test/integration/opaTests.qunit.js:1:1

My ui5.yaml:

specVersion: '2.6'
metadata:
  name: myApplication
type: application
server:
  customMiddleware:
    - name: fiori-tools-proxy
      afterMiddleware: compression
      configuration:
        ignoreCertError: false
        ui5:
          path:
            - /resources
            - /test-resources
          url: https://sapui5.hana.ondemand.com/

My karma.conf.js:

module.exports = function(config) {
  config.set({

    frameworks: ["ui5"],

    ui5: {
    },

    browsers: ["Chrome"]

  });
};

Once i remove the loading of the ui5 sources using the fiori-tools-proxy the tests also run with karma perfectly fine.

This seems to be a restriction of the fiori-tools-proxy middleware. It seems that it is proxying requests directly to the UI5 deployment without rewriting the path.

This works for paths like when using serve:
http://localhost:8080/resources/sap/ui/thirdparty/qunit-2.js
rewritten to
https://sapui5.hana.ondemand.com/resources/sap/ui/thirdparty/qunit-2.js
but it doesn't work for the paths in the karma setup:
http://localhost:9876/base/webapp/resources/sap/ui/thirdparty/qunit-2.js
rewritten to
https://sapui5.hana.ondemand.com/base/webapp/resources/sap/ui/thirdparty/qunit-2.js
which results in a 404

I think you should reach out to the Fiori Tools team at https://github.com/SAP/open-ux-tools/

As a workaround, you could use a different ui5.yaml in your karma configuration, which does not configure the fiori-tools-proxy middleware.