angular / angular/components

feat(cdk/testing): Consider adding a `TestElementPromise` class

Open
#21,183 5 comments 0 reactions 0 assignees View on GitHub
area: cdk/testing feature P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

#### Feature Description

@yjaaidi proposed this idea in https://github.com/angular/components/issues/20871. We could create a subclass of `Promise` that would allow calling `TestElement` methods directly on the Promise. Example: https://stackblitz.com/edit/test-element-promise

#### Use Case

This would allow people to write cleaner test code, e.g.

```ts
await harness.host().getText();
```

Instead of:

```ts
await (await harness.host()).getText();
// or
await harness.host().then(host => host.getText());
```

The idea would need a design doc and discussion with the team before proceeding.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the TestElement and harness APIs, then compare the linked proposal with the TestElementPromise example. Produce a design document covering the Promise subclass and direct TestElement method calls, and use team discussion to determine whether the feature should proceed.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.