Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Ng19=next - Forgot to flush TestBed? MockRender cannot be used without a reset #10306

Open
DDtMM opened this issue Oct 27, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@DDtMM
Copy link

DDtMM commented Oct 27, 2024

Description of the bug

After upgrading to Angular 19.0.0-next.11 from Angular 18.x my tests my tests that use MockRender started getting the error: "Forgot to flush TestBed? MockRender cannot be used without a reset..." These tests all worked properly before. I also tried taking the advice and calling MockRender like this fixture = MockRender('', {}, { reset: true });, but it did not help.

An example of the bug

You can see an example of the Angular 18 versions here: https://github.com/DDtMM/angular-signal-generators/blob/main/projects/signal-generators/src/lib/signals/tween-signal.spec.ts. The stack trace pointed to the MockRender() calls in the beforeEach. I'm assuming Angular changed something that affects ngMocks since I'm using it in a very minimal fashion for my project.

 beforeEach(() => {
    fixture = MockRender(); // <-- error here.
    injector = fixture.componentRef.injector;
  });

Expected vs actual behavior

Don't throw that error.

@DDtMM DDtMM added the bug Something isn't working label Oct 27, 2024
@jahusa02
Copy link

jahusa02 commented Nov 5, 2024

I noticed that as well.
It started with the flip of the default for standalone from false to true.
The logic how ng-mocks determines standalone components is the culprit I guess

@re-alam
Copy link

re-alam commented Nov 26, 2024

I've submitted a PR (#10583) to fix the "Forgot to flush TestBed?" error in Angular 19 when using MockRender.

If you've been experiencing this bug, please review the PR and let me know if it works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants