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: Zoneless test #11099

Open
handja opened this issue Feb 27, 2025 · 0 comments
Open

Bug: Zoneless test #11099

handja opened this issue Feb 27, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@handja
Copy link

handja commented Feb 27, 2025

I've activated Zoneless on my project, but now I encounter an issue on unit test with ng-mocks (issue not encountered with TestBed)

Issue : Error: NG0908: In this configuration Angular requires Zone.js

TS FILE

import { Component, input } from '@angular/core';

@Component({
  selector: 'esac-test',
  template: '',
})
export class TestComponent {
  readonly count = input(0);
}

SPEC FILE

import { provideExperimentalZonelessChangeDetection } from '@angular/core';
import { TestComponent } from './control.component';
import { MockBuilder, MockedComponentFixture, MockRender } from 'ng-mocks';

fdescribe('TestComponent', () => {
  let component: TestComponent;
  let fixture: MockedComponentFixture<TestComponent>;

  beforeEach(async () => {
    await MockBuilder(TestComponent).provide(provideExperimentalZonelessChangeDetection());
    fixture = MockRender(TestComponent);
    component = fixture.point.componentInstance;
  });

  it('should create', () => {
    fixture.componentRef.setInput('count', 1);
    expect(component).toBeTruthy();
  });
});

@handja handja added the bug Something isn't working label Feb 27, 2025
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

1 participant