feature: template coverage - #433
Open
lifeart wants to merge 1 commit into
Open
Conversation
lifeart
force-pushed
the
track-coverage-for-gts-hbs-files
branch
3 times, most recently
from
March 18, 2026 07:57
316b242 to
3ca5027
Compare
feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage feature: template coverage
lifeart
force-pushed
the
track-coverage-for-gts-hbs-files
branch
from
March 18, 2026 10:00
3cd51e7 to
d6b09e8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Template Coverage
This addon supports branch coverage for Glimmer/Handlebars templates (
.hbsfiles and<template>tags in.gjs/.gtsfiles). WhenCOVERAGE=true, templates are automatically instrumented during compilation to track which branches are executed.What is tracked
{{#if}},{{#unless}}(with and without{{else}}){{if condition "yes" "no"}},(if condition "a" "b"), and theunlessequivalents{{#each}}/{{#each-in}}with{{else}}(items vs empty list){{else if}}chainsHow it works
A Glimmer AST plugin runs at build time and:
{{coverageInit}}at the template root to register an Istanbul-compatible coverage object inwindow.__coverage__{{coverageMark}}at the start of each block branch body to record block branch hits(coverageCond)to record inline branch hits reactivelyThe coverage data integrates seamlessly with the existing Istanbul pipeline, appearing in the same HTML/LCOV/JSON reports alongside JavaScript coverage.
Setup for .hbs files
No additional setup is needed. The AST plugin is registered automatically via
setupPreprocessorRegistrywhen the addon is installed. Branch coverage for.hbsfiles works out of the box.Setup for .gjs/.gts files (strict mode)
For
.gjs/.gtsfiles using<template>tags, coverage helpers need to be in JavaScript scope. ThebuildBabelPlugin()method already includes a Babel plugin that injects the necessary imports automatically. No extra configuration is required if you already havebuildBabelPlugin()in yourember-cli-build.js.