Angular-cli: Feature Request: Generate tests with jasmine.pending()

Created on 19 Jun 2017  路  4Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

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

Versions.

@angular/cli: 1.1.1
node: 7.10.0
os: darwin x64
@angular/animations: 4.2.2
@angular/common: 4.2.2
@angular/compiler: 4.2.2
@angular/core: 4.2.2
@angular/flex-layout: 2.0.0-rc.1
@angular/forms: 4.2.2
@angular/http: 4.2.2
@angular/material: 2.0.0-beta.6
@angular/platform-browser: 4.2.2
@angular/platform-browser-dynamic: 4.2.2
@angular/router: 4.2.2
@angular/cli: 1.1.1
@angular/compiler-cli: 4.2.2
@angular/language-service: 4.2.2

Repro steps.


ng g c componentName

The log given by the failure.


(no logs)

Desired functionality.


Instead of generating a test that only passes:

it('should be created', () => {
    expect(component).toBeTruthy();
});

We could write a test that indicates is pending. Something like so:

it('pending...should be created', () => {
    expect(component).toBeTruthy();
    pending();
});

or just add a new spec, like so:

it('pending...write tests', () => {
    pending();
});

Mention any other details that might be useful.

More about the pending method: https://jasmine.github.io/2.0/introduction.html#section-Pending_Specs

My suggestion is to avoid cases when the developer uses the generator from angular-cli, but doesn't re-write the test when it should.

3 (nice to have) inconvenient feature

Most helpful comment

馃憤 I quite like this as the tests generated by the CLI, while they will pass, aren't really testing anything.

Marking them as pending() or xit by default lets developers know that they haven't actually implemented tests for the generated items yet.

All 4 comments

I'm curious what others have to say, this is interesting. I was not aware of the pending function.

馃憤 I quite like this as the tests generated by the CLI, while they will pass, aren't really testing anything.

Marking them as pending() or xit by default lets developers know that they haven't actually implemented tests for the generated items yet.

It's possible to fork the existing schematics and customize them according to your use case. Let us keep this outside the scope of the CLI for now.

Please feel free to open a new issue in case I'm missing something.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

delasteve picture delasteve  路  3Comments

daBishMan picture daBishMan  路  3Comments

brtnshrdr picture brtnshrdr  路  3Comments

jmurphzyo picture jmurphzyo  路  3Comments

JanStureNielsen picture JanStureNielsen  路  3Comments