Aalexbit-codemod

angularjs-test-coverage-inventory

Mine AngularJS test coverage signals (nearby specs, density, gaps); read-only metrics

miningmetricsangularjscode-miningmigration-assessmenttest_coverage_signal
PRO
0 executions

Run locally

npx codemod angularjs-test-coverage-inventory

This is a Pro codemod. Preview changes and insights for free, no login or code sharing required. Applying changes and accessing insights requires a paid plan and sign in.Learn more

angularjs-test-coverage-inventory

Read-only mining codemod that correlates AngularJS app artifacts (module,
component, controller, service, directive registrations) with test signals
found in the same file, to help estimate test coverage risk before an
AngularJS → Angular migration.

Emits the test_coverage_signal metric. Does not modify any files.

What it detects

For every JS/TS/TSX file scanned:

  1. test_file — the filename matches a common test convention:
    *.spec.js, *.test.js, *_test.js, *-test.js.
  2. test_marker — a Jasmine/Mocha/angular-mocks call is present in the
    file: describe(, xdescribe(, fdescribe(, it(, xit(, fit(,
    beforeEach(, afterEach(, beforeAll(, afterAll(, inject(,
    module(.
  3. angular_artifact_without_test_markers — the file registers an
    AngularJS module/component/controller/service/directive (via
    angular.module('app').<method>(...)), the filename does not look
    like a test file, and the file contains no test markers of its own.

Cardinalities

FieldDescription
fileRelative file path
line1-based line number of the match
snippetTruncated source snippet (whitespace-collapsed, 120 chars)
signal_kindtest_file | test_marker | angular_artifact_without_test_markers
artifact_typeFor test_file: test_file. For test_marker: the marker name (e.g. describe, inject). For the missing-test signal: the AngularJS registration method (module, component, controller, service, directive).
migration_categoryAlways testing
risklow | medium | high | critical
automationfull | partial | manual
effort_pointsFibonacci effort estimate (1, 2, 5, ...)
recommended_phasephase-1 .. phase-5

Risk/effort heuristics:

  • Jasmine/Mocha lifecycle markers (describe, it, beforeEach, ...) are
    low risk / fully automatable (effort_points: 1) — syntax carries over
    almost directly to Jest/Karma+Jasmine on Angular.
  • inject(...) and module(...) (from angular-mocks) are medium risk /
    partially automatable (effort_points: 2) since they require a real
    rewrite to TestBed.configureTestingModule(...).
  • AngularJS registrations with no test markers in the same file are
    flagged high risk / manual (effort_points: 5, phase-1): write or
    backfill tests before migrating that code, since regressions will be
    invisible otherwise.

Known limitation: file-local analysis only

JSSG codemods run per-file and cannot see sibling files. This codemod
cannot confirm whether a separate *.spec.js exists elsewhere for a
given source file — it can only tell you "this file has no test markers in
it". A source file with describe(/it( in a different file will still
be flagged angular_artifact_without_test_markers here. Cross-reference this
metric's file values against your test file naming/co-location convention
(e.g. foo.js next to foo.spec.js) to filter out true negatives during
assessment.

Each AngularJS method-chain call site (e.g. every .module('app') in
angular.module('app').controller(...)) is counted independently, so a
single logical module can produce multiple module entries — this mirrors
how many risky call sites exist in the source, not how many distinct modules
exist.

Installation

bash

Development

bash

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.