Skip to content

Bug: Upgraded to Angular 21 - Error: TestModule declaration has been passed into ng-mocks without Angular decorators #12725

@Ryan-Cav

Description

@Ryan-Cav

Description of the bug

Upgraded to Angular 21 - Error: TestModule declaration has been passed into ng-mocks without Angular decorators

An example of the bug

Any and all MockProvider or MockProviders call results in the following error:

Error: TestModule declaration has been passed into ng-mocks without Angular decorators. Therefore, it cannot be properly handled. Highly likely, ng-mocks is imported in production code, or got a class without Angular decoration. Otherwise, please create an issue on github: https://github.com/help-me-mom/ng-mocks/issues/new?title=False%20positive%20ng-mocks%20not%20in%20JIT. Thank you in advance for support.
at error_missing_decorators (node_modules/ng-mocks/index.mjs:1:34634)
at node_modules/ng-mocks/index.mjs:1:35255
at core_reflect_module_resolve (node_modules/ng-mocks/index.mjs:1:35682)
at applyPlatformOverrideDef (node_modules/ng-mocks/index.mjs:1:123820)
at applyPlatformOverrides (node_modules/ng-mocks/index.mjs:1:124662)
at TestBedImpl.call (node_modules/ng-mocks/index.mjs:1:125950)
at TestBedImpl.configureTestingModule (node_modules/ng-mocks/index.mjs:1:108349)
at UserContext. (src/app/app.component.spec.ts:10:19)
at Generator.next ()
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:3:1)

Tried multiple fresh npm installs, angular cache cleans, etc and cannot get around this without just moving off of ng-mocks yet it seems no one else has this issue...

Expected vs actual behavior

MockProvider calls work vs missing decorators error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions