Skip to content

Fix broken specs so ng test builds and passes - #160

Merged
matthewberry merged 1 commit into
mainfrom
mjberry/fix-broken-specs
Oct 28, 2026
Merged

matthewberry merged 1 commit into
mainfrom
mjberry/fix-broken-specs

Conversation

@matthewberry

Copy link
Copy Markdown
Collaborator

Problem

ng test on main doesn't build. landing-page.component.spec.ts uses FormsModule and InputTextareaModule but doesn't import them, so the whole test bundle fails to compile. If that file is fixed, 5 of the 6 tests still fail because their dependencies aren't provided.

Change

Only spec files change. No app code is touched.

  • landing-page: add the two missing imports.
  • All other specs: provide what the code under test injects:
    • HttpClientTestingModule, so no real HTTP requests are made
    • ApiModule.forRoot(() => new Configuration())
    • EnvironmentService
  • SequenceService / ConfigurationComponent: use NgxMatomoTrackerModule.forRoot({ disabled: true, ... }). In ngx-matomo 4.0.1, disabled switches to NoopMatomoTracker and NoopMatomoInitializer, so the tests load no script and send no tracking.
  • ConfigurationComponent:
    • Replace NgHcaptchaService with an empty stub. The component only calls it on submit, so should create never uses it.
    • Import the PrimeNG modules whose controls use ngModel (SelectButton, RadioButton, Checkbox). Without them the test fails with NG01203, no value accessor.
  • App / Results / Configuration components: add NO_ERRORS_SCHEMA so the specs don't have to import every PrimeNG and router module their templates use.

The existing tests are only should create / should be created checks. This PR gets them running and passing; it doesn't add coverage.

Testing

npx ng test --watch=false --browsers=ChromeHeadless: 6 of 6 pass, with no errors or warnings in the output. On main it fails to compile.

Conflicts with #159

#159 also edits the imports at the top of results.component.spec.ts. A test merge of the two branches conflicts in that file. Whichever PR merges second will need a small rebase that keeps both sets of imports.

landing-page spec referenced FormsModule and InputTextareaModule without
importing them, which broke compilation of the whole test bundle. The
remaining specs failed at injection: add HttpClientTestingModule, the
generated ApiModule config, EnvironmentService, a disabled Matomo
tracker, and a stub hCaptcha service where needed, plus NO_ERRORS_SCHEMA
for component templates that use modules the specs don't import.
@matthewberry
matthewberry merged commit 4730799 into main Oct 28, 2026
1 check passed
@matthewberry
matthewberry deleted the mjberry/fix-broken-specs branch October 28, 2026 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant