Skip to content

feat(cdk/testing): cdk/testing should not depend on @angular/core #22015

Open
@yjaaidi

Description

@yjaaidi

Feature Description

As discussed today during the test harnesses community chat (AngularCommunity/angular-missions#5), it was noticed that @angular/cdk/testing depends on @angular/core/testing which depends on @angular/core due to the following import:

import {ComponentFixture, flush} from '@angular/core/testing';

The flush function which is imported in order to handle fake async tests ends up importing @angular/core.
(I think that ComponentFixture isn't a problem because it is only used as a type so it's not bundled.)

The problem with this is that libraries like cypress-harness which depend on @angular/cdk/testing end up loading @angular/core and eventually slowing down tests as mentioned here jscutlery/devkit#6.
It's not just a performance issue but it feels wrong to always depend on @angular/core just because fake async tests need flush.

😅 It's too late in the evening for my brain to come up with precise suggestions... but I can hear some voices in my head:

  • Dependency Inversion
  • Move fake async to @angular/core/testing/fake-async or such
  • YOLO, Please Repeat Yourself (cc. @jeffwhelpley 😉): _Zone && _Zone[_Zone.__symbol__('fakeAsyncTest')].flush()

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/testingfeatureThis issue represents a new feature or feature request rather than a bug or bug fixneeds: discussionFurther discussion with the team is needed before proceeding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions