Skip to content

Generation of test: Use Classname.name in describe of spec files instead of 'Classname' #19026

@Rogier-blip

Description

@Rogier-blip

🚀 feature request

When a spec file is generated by the CLI use Classname.name instead of the 'Classname'.

Relevant Package

@angular/cli

Description

It would be nice if the spec files would be generated in a way that makes them adaptable to change.

If a test is generated by the CLI the initial describe looks like this:

...
describe('AppComponent', () => {
...

When I change the name of the app component from AppComponent to AppComponent1. I have to change the name of the test by hand.

Describe the solution you'd like

The solution that I have in mind is to use the .name property of the typescript class. The describe would have the following structure.

...
describe(AppComponent.name, () => {
...

Now when the AppComponent name is changed through an IDE. The test name is automatically changed.

Cheers 🐵

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions