spectator icon indicating copy to clipboard operation
spectator copied to clipboard

Provide an option to run unit tests without automatic resolution of providedIn root services

Open szabyg opened this issue 4 years ago • 0 comments

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

Services providedIn root are auto-resolved in unit tests. Therefore missing mock for the service stays a hidden issue. For unit testing it would be better if the test fails and we as developers would have to provide a proper mock for the service or provide it explicitly.

This issue is discussed in detail here: https://github.com/angular/angular/issues/25593 https://github.com/angular/angular/pull/26088

Expected behavior

Given a central(?) config/property we can prohibit auto-providing services with a providedIn root declaration.

Minimal reproduction of the problem with instructions

See the related angular issue and PR.

What is the motivation / use case for changing the behavior?

It would be nice if spectator would have an option for this until the angular world finds a solution it can live with. And in the meantime the rest of us would have another reason for using spectator.

Environment

Angular version: 9.1.0

Browser: Browser-independent

For Tooling issues:

  • Node version: independent
  • Platform: independent

szabyg avatar Jun 08 '21 13:06 szabyg