Skip to content

Feature Request: Generate component specs with DebugElement and HTMLElement predefined and assigned #8279

Description

@G1itcher

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request

Versions.

@angular/cli: 1.4.9
node: 6.9.2
os: win32 x64
@angular/animations: 4.4.6
@angular/common: 4.4.6
@angular/compiler: 4.4.6
@angular/core: 4.4.6
@angular/forms: 4.4.6
@angular/http: 4.4.6
@angular/platform-browser: 4.4.6
@angular/platform-browser-dynamic: 4.4.6
@angular/router: 4.4.6
@angular/cli: 1.4.9
@angular/compiler-cli: 4.4.6
@angular/language-service: 4.4.6
typescript: 2.3.4

Repro steps.

ng g c componentName

The log given by the failure.

Not an error

Desired functionality.

Almost every component will require tests that examine the generated HTML element. I find myself having to copy the same few lines:

import { DebugElement } from '@angular/core';
...
let de: DebugElement;
let el: HTMLElement;
...
de = fixture.debugElement;
el = de.nativeElement;

in almost every component spec. If I'm not the only one, perhaps it would make sense to put this into the component spec template?

Mention any other details that might be useful.

This follows the testing patterns described on the AngularIO documentation (https://angular.io/guide/testing)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P5The team acknowledges the request but does not plan to address it, it remains open for discussionfeatureLabel used to distinguish feature request from other issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions