Skip to content

Provide the ability to test directives that contain input signals without wrapper components #54164

Description

@jamcoupe

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

Given the following simple directive with a signal input:

@Directive({
  selector: '[appSimple]',
  standalone: true,
  host: {
    '(click)': 'doSomething()',
  }
})
export class SimpleDirective {
  data = input.required<string>();

  doSomething() {
    console.log(this.data());
  }
}

There is no way for me to write a test because I can not create a "DirectiveFixture" where I can "setInput"

Proposed solution

Provide a similar approach as TestBed.compileComponents but for directives.

Alternatives considered

Stick with requiring wrapper components to test, but add documentation when input signals become available as part of the public API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: testingIssues related to Angular testing features, such as TestBed

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions