Skip to content

Component with attribute selector #263

Closed
@mleimer

Description

@mleimer

Problem

Based on the examples https://github.com/testing-library/angular-testing-library/blob/main/apps/example-app/src/app/examples/02-input-output.ts and https://github.com/testing-library/angular-testing-library/blob/main/apps/example-app/src/app/examples/02-input-output.spec.ts

Given that a component contains an attribute within its selector
e.g. app-fixture[value]

Then it is not possible to render the component with:
await render(InputOutputComponent, { componentProperties: { value: 47, sendValue: { emit: sendValue, } as any, }, });

Instead, the template way must be chosen:
await render('<app-fixture [value]="47" (sendValue)="sendValue($event)" (clicked)="clicked()"></app-fixture>', { declarations: ['InputOutputComponent'], componentProperties: { sendValue: sendSpy, }, });

Suggestion

  • Add documentation that the regular render does not work with attribute components OR if there is a way to make it work, enhance the code base
  • Update the example, as it uses a deprecated render-method where the template is passed as a property in the second argument instead of the first argument.

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