Skip to content

Commit

Permalink
documentation(coverage): how to for typescript projects #35
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBuchholz committed Oct 8, 2023
1 parent 093b877 commit 4134f55
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion docs/coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ In this mode, source files are directly manipulated by `ui5-test-runner`.

It is possible to extract code coverage using the remote mode.

### @ui5/middleware-code-coverage
### JavaScript `@ui5/cli` projects : `@ui5/middleware-code-coverage`

The [`@ui5/middleware-code-coverage`](https://www.npmjs.com/package/@ui5/middleware-code-coverage) middleware is capable of instrumenting the source files on the fly (by adding `?instrument=true` to the URL of the file).

Expand Down Expand Up @@ -86,6 +86,36 @@ server:
**Implementation note** : unlike the expected usage of the middleware, `ui5-test-runner` generates the coverage report. It forces the runner to download all the covered source files locally to ensure the report can be generated.

### TypeScript `@ui5/cli` projects : tweaking `ui5-tooling-transpile`

The [`ui5-tooling-transpile`](https://www.npmjs.com/package/ui5-tooling-transpile) middleware converts TypeScript into JavaScript while serving the application. Its configuration can be tweaked to also achieve instrumentation during this step.

```yaml
specVersion: "3.0"
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
```

**NOTE** : You may consider tweaking in a distinct configuration file and use the `--config` option to run it.

For instance : `ui5 serve --config ui5-coverage.yaml`

### coverage-proxy *(experimental)*

If the remote server does not provide instrumented source files, an experimental approach consists in using `ui5-test-runner` as a 'proxy' to get the files. It will instrument the sources on the fly.
Expand Down

0 comments on commit 4134f55

Please sign in to comment.