Skip to content

Re-enable component specs (NgModule → standalone or module-scope fix) #4864

@Yicong-Huang

Description

@Yicong-Huang

Task Summary

Re-enable the 43 *.component.spec.ts files that #4862 had to exclude. The new @angular/build:unit-test builder type-checks each component's template against the bundle's standalone scope (not the declaring NgModule's scope), so NgModule-declared components fail to resolve their template directives — [ngModel], <nz-dropdown-menu>, custom selectors like <texera-user-avatar>, etc. ~1000 NG8002/NG8001/NG8004 errors before exclusion.

Two viable approaches

A. Convert components to standalone (Angular's recommended direction)

For each affected component:

  1. @Component({ standalone: false, ... })@Component({ standalone: true, imports: [CommonModule, FormsModule, ...moduleSpecificModules], ... })
  2. Remove the component from the declaring NgModule's declarations array; add to imports instead.

Pros: future-proof, matches Angular team direction, eliminates the implicit NgModule scope dependency.
Cons: per-component imports list must be derived from what each template uses; ~43 components to migrate.

B. Schema overrides at the spec level

For each component spec, add schemas: [CUSTOM_ELEMENTS_SCHEMA] to TestBed setup so the strict template checker tolerates unknown elements.

Pros: faster to apply.
Cons: silently masks real bugs (typos in element names won't fail tests), and only addresses NG8001-style errors — [ngModel] not being resolved is NG8002 which schemas don't suppress.

Recommendation: A. Doing this in chunks (group by feature area) keeps each PR reviewable.

Affected files

43 files matching **/*.component.spec.ts. Currently excluded by tsconfig.spec.json and angular.json's test-target exclude.

Definition of done

  • All 43 component specs compile under the unit-test builder
  • Each runs to either passing or a documented runtime issue (likely a separate follow-up)
  • Exclusion entries removed from tsconfig.spec.json and angular.json

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions