ArnaudBuchholz / ui5-test-runner

A test runner for UI5 applications enabling parallel execution of tests.
https://arnaudbuchholz.github.io/ui5-test-runner/
MIT License
19 stars 9 forks source link

Document Typescript code coverage support #35

Closed ArnaudBuchholz closed 12 months ago

ArnaudBuchholz commented 1 year ago

Experiment in progress, may end up into documentation

heimwege commented 1 year ago

Works for me pretty well with TS, ui5-middleware-fe-mockserver and ui5-tooling-transpile in the following setup:

nycrc config enhanced by

    "extends": "@istanbuljs/nyc-config-babel"

babel config enhanced by

  "plugins": ["istanbul"]

run configurations in package.json

"ui5:test:server": "ui5 serve --config ./ui5-karma.yaml",
"ui5:test:runner": "ui5-test-runner --port 8081 --url http://localhost:8080/test/testsuite.qunit.html --coverage true --fail-opa-fast --coverage-settings ./.nycrc.json",
"ui5:test": "start-server-and-test ui5:test:server http://localhost:8080/ ui5:test:runner"

versions in package.json

"ui5-test-runner": "3.2.0",
"@istanbuljs/nyc-config-babel": "3.0.0",
"babel-plugin-istanbul": "6.1.1",
"ui5-tooling-transpile": "0.7.10"
ArnaudBuchholz commented 1 year ago

@heimwege awesome, thx.

ArnaudBuchholz commented 12 months ago

@heimwege I found a 'better' way that does not impact the build. Indeed, defining a babel config overrides the normal build. Instead, you may specify the babel config inside a specifc ui5.yaml, like this :

ui5-coverage.yaml

specVersion: "3.0"
metadata:
  name: sample.ts
type: application
framework:
  name: SAPUI5
  version: "1.119.0"
  libraries:
    - name: sap.m
    - name: sap.ui.core
    - name: themelib_sap_horizon
builder:
  customTasks:
    - name: ui5-tooling-transpile-task
      afterTask: replaceVersion
server:
  customMiddleware:
    - name: ui5-tooling-transpile-middleware
      afterMiddleware: compression
      configuration:
        debug: true
        babelConfig:
          sourceMaps: true
          ignore:
          - "**/*.d.ts"
          presets:
          - - "@babel/preset-env"
            - targets: defaults
          - - transform-ui5
            - overridesToOverride: true
          - "@babel/preset-typescript"
          plugins:
          - istanbul
heimwege commented 12 months ago

Thanks for the hint. I will give it a try. Nevertheless I'm afraid I still might need the babel file because the fe mockserver does currently not support the tooling transpile 🙈 Thus I need to have an explicit babel transpile for the mockserver .ts sources (at least in case there are any custom mockserver extensions) before starting the mockserver itself. But I already addressed this and hopefully one day this will no longer be needed ☺️

ArnaudBuchholz commented 12 months ago

Documented in 3.3.5