Skip to content

Make spectator zoneless-compatible #663

Open
@devfservant

Description

@devfservant

Description

Since Angular 18, zoneless applications are available experimentally.
The main advantages are described here: https://angular.dev/guide/experimental/zoneless
It is possible to configure TestBed accordingly to ensure the components under test are zoneless-compatible:

TestBed.configureTestingModule({
  providers: [provideExperimentalZonelessChangeDetection()]
});

The spectator equivalent looks like:

const createComponent = createComponentFactory({
    component: MyComponent,
    providers: [provideExperimentalZonelessChangeDetection()],
  });

But, it does not work, as it uses waitForAsync under the hood:
https://github.com/ngneat/spectator/blob/v19.0.0/projects/spectator/src/lib/spectator/create-factory.ts#L127

MyComponent › should render
    thrown: "Zone is needed for the waitForAsync() test helper but could not be found. Please make sure that your environment includes zone.js"

It would be a huge improvement to see Spectator be zoneless-compatible.

Thanks for all your amazing work

Proposed solution

--

Alternatives considered

No alternative considerations.

Do you want to create a pull request?

No

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions