Angular-cli: Default generated app should not fail ng test

Created on 24 May 2018  路  7Comments  路  Source: angular/angular-cli

Versions

Angular CLI: 6.0.3
Node: 8.11.1
OS: darwin x64
Angular: 6.0.3
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.3
@angular-devkit/build-angular     0.6.3
@angular-devkit/build-optimizer   0.6.3
@angular-devkit/core              0.6.3
@angular-devkit/schematics        0.6.3
@ngtools/webpack                  6.0.3
@schematics/angular               0.6.3
@schematics/update                0.6.3
rxjs                              6.2.0
typescript                        2.7.2
webpack                           4.8.3

Repro steps

ng new my-dream-app
cd my-dream-app
ng test

Observed behavior

AppComponent should render title in a h1 tag FAILED
    Expected ' Welcome to app! ' to contain 'Welcome to my-dream-app!'.
        at UserContext.<anonymous> src/app/app.component.spec.ts:25:54)

Desired behavior

By default the generated app should not error

devkibuild-angular

Most helpful comment

Your html page does not have h1 tag.
comment below line from app.component.spec.ts
//expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');

All 7 comments

I've just created a new project and I have the same problem. Moreover, i can't navigate to the file by clicking on it in the chrome console, and the page is not reloaded when the file is edited.

I want to learn unit testing with angular to my team, but 'as-is', there is too many problems :(

I have the same issue. Also fails on e2e test

Was there any solution to this issue? I just installed a fresh install last night and am getting this error this morning while running tests.

Same here, but I\m not worrying, guys are going to fix it eventually.

Your html page does not have h1 tag.
comment below line from app.component.spec.ts
//expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');

As far as I can tell we have since fixed this.

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