Repository navigation
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
aklkv
added a commit
to aklkv/ember-cli-code-coverage
that referenced
this pull request
Sep 11, 2026
Closes the three gaps between this branch and what issue ember-cli-code-coverage#431 and PRs ember-cli-code-coverage#433/ember-cli-code-coverage#434 set out to do. Strict-mode template coverage (.gjs/.gts): - createTemplateCoveragePlugin now takes `strict: true`, emitting camelCase helper references (coverageMark) instead of dash-cased ones. The two can't be shared: loose mode resolves helpers by name through the classic resolver, which current ember-resolver versions require to be dash-cased — they removed the camelCase fallback as a deliberate bug fix. Strict mode has no resolver at all, so every reference must be a JS binding, and a dash isn't a valid identifier character. - New templateCoverageImportPlugin supplies those bindings, injecting the three helper imports from a Babel pre() hook so they exist before babel-plugin-ember-template-compilation validates template scope. - Skip templates outside the project and anything under node_modules: Embroider rewrites classic v1 addon dependencies into v2-compatible template() calls through the host app's own `transforms`, and those never went through the import plugin, so instrumenting them broke the build outright. - Derive the coverage key from `env.filename` when the preprocessor registry didn't set `env.meta.moduleName` (it never does on the strict-mode path), so entries no longer collapse onto a shared placeholder key. - Suffix that key so it doesn't resolve to a real file. A .gjs file's own JS coverage has a real source map, and applying it to template positions read off the pre-compilation AST produced invalid columns and crashed reporting for the whole payload. Fix adjustCoverage discarding coverage on key collision: Two raw keys resolving to the same file overwrote rather than merged, so one silently won. Merges via istanbul-lib-coverage now — the template and JS halves of a .gjs file depend on it, and it was already wrong for any other collision. Standalone CLI: `coverage-merge` bin runs the merge without ember-cli, for projects with no ember-cli command layer. Takes optional --root and --config. New /core subpath export, exposing the config, path-mapping and report utilities without pulling in babel, vite, or testem code. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
aklkv
added a commit
to aklkv/ember-cli-code-coverage
that referenced
this pull request
Sep 11, 2026
Closes the three gaps between this branch and what issue ember-cli-code-coverage#431 and PRs ember-cli-code-coverage#433/ember-cli-code-coverage#434 set out to do. Strict-mode template coverage (.gjs/.gts): - createTemplateCoveragePlugin now takes `strict: true`, emitting camelCase helper references (coverageMark) instead of dash-cased ones. The two can't be shared: loose mode resolves helpers by name through the classic resolver, which current ember-resolver versions require to be dash-cased — they removed the camelCase fallback as a deliberate bug fix. Strict mode has no resolver at all, so every reference must be a JS binding, and a dash isn't a valid identifier character. - New templateCoverageImportPlugin supplies those bindings, injecting the three helper imports from a Babel pre() hook so they exist before babel-plugin-ember-template-compilation validates template scope. - Skip templates outside the project and anything under node_modules: Embroider rewrites classic v1 addon dependencies into v2-compatible template() calls through the host app's own `transforms`, and those never went through the import plugin, so instrumenting them broke the build outright. - Derive the coverage key from `env.filename` when the preprocessor registry didn't set `env.meta.moduleName` (it never does on the strict-mode path), so entries no longer collapse onto a shared placeholder key. - Suffix that key so it doesn't resolve to a real file. A .gjs file's own JS coverage has a real source map, and applying it to template positions read off the pre-compilation AST produced invalid columns and crashed reporting for the whole payload. Fix adjustCoverage discarding coverage on key collision: Two raw keys resolving to the same file overwrote rather than merged, so one silently won. Merges via istanbul-lib-coverage now — the template and JS halves of a .gjs file depend on it, and it was already wrong for any other collision. Standalone CLI: `coverage-merge` bin runs the merge without ember-cli, for projects with no ember-cli command layer. Takes optional --root and --config. New /core subpath export, exposing the config, path-mapping and report utilities without pulling in babel, vite, or testem code.
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.