Skip to content

[Bug]: Missing @angular/platform-browser-dynamic when installed in new projects #12

Description

@MelGidsen

Checklist

  • I have searched the existing issues and have not found a duplicate
  • I have read the README and documentation and have not found a solution
  • I agree to follow the OpenNG Foundation Code of Conduct

What happened?

The package currently uses BrowserDynamicTestingModule from @angular/platform-browser-dynamic/testing, which has been deprecated in Angular 20. Since this package only declares it as a devDependency and it is not installed by default anymore, running tests will raise an error claiming that package could not be found.

Instead of adding it as a peerDependency, I'd recommend replacing it with BrowserTestingModule from @angular/platform-browser/testing instead. This follows the Angular Teams migration suggestion.

Steps to reproduce

  1. Create an Angular 22 project from scratch
  2. Install the latest @openng/spectator package
  3. Use spectator in a test spec
  4. run tests, observe error

Expected behavior

Spectator does not declare dependencies, so no further installation of packages should be necessary.

Actual behavior

We have to install @angular/platform-browser-dynamic for spectator to work.

Minimal reproduction

https://github.com/MelGidsen/spectator-missing-declaration

Library version

1.0.1

Angular version

>=22.0.0

Node version

24.18.0

Package manager

npm

Browser(s)

Chrome

Environment details

- Test Runner: Vitest

Angular application setup

None

Angular context

  • SSR (Server-Side Rendering) is involved
  • Zoneless change detection is enabled

Relevant log output

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL   spectator-missing-declaration  src/app/to-string.pipe.spec.ts [ src/app/to-string.pipe.spec.ts ]
Error: Cannot find package '@angular/platform-browser-dynamic' imported from C:\Users\gaida\Workspace\Projekte\adease\openng-spectator-bug\spectator-missing-declaration\node_modules\@openng\spectator\fesm2022\openng-spectator.mjs
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

Screenshots

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions