# Setting Up Test Coverage Profiling for Javascript/Typescript

In order to use the Test Gap analysis, you’ll need to upload test coverage to Teamscale.

To collect coverage in the browser, currently, only the Istanbul profiler's JSON format is supported by Teamscale. For most other languages the profiler creates a report that can be directly uploaded to Teamscale. Since JavaScript may be minified and TypeScript is always transpiled to JavaScript before execution in the browser. Therefore, the coverage reports refer to the transformed code instead of the source code. Teamscale needs the source map files to interpret the coverage files.

Teamscale allows you to upload the source maps ahead of time, e.g., when they are created during the build process. Then, when uploading coverage files, it will use the mapping files to interpret the coverage information. Since every time you build your application, new mapping files are generated, Teamscale needs to know, which mapping files to use when you upload coverage. Thus, during the upload of the mapping files, you must provide a version string (any unique string will do, e.g., a revision number). You must provide the exact same version string again when uploading coverage files that belong to those mapping files.

Test Gap analysis for JavaScript/TypeScript data flow


Please note that errors in the source maps can lead to subtle misalignment of the covered lines and thus to wrong coverage results. Please make absolutely sure that source maps are configured correctly for your entire build pipeline and that they correctly map back to your source files. Some minification/bundling tools are known to e.g., produce off-by-one source maps.

# Uploading Source Maps

The following is an example of how to upload source map files using curl:

curl --request POST \
--user bob:e434mikm35d \
--form "file=@./source.map" \

The branch:timestamp must be the branch name and commit timestamp in milliseconds of the commit which was processed by the build to generate the mapping file.

# Uploading Coverage files

The following is an example of how to upload Istanbul coverage files using curl:

curl --request POST \
--user bob:e434mikm35d \
--form "report=@./coverage.json" \