Skip to content

All tests failed if order of imports is changed in test.ts #9641

@lbar

Description

@lbar

Versions

Angular CLI: 1.6.8
Node: 8.2.0
OS: win32 x64
Angular: 5.2.5
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.6.8
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.8
@schematics/angular: 0.1.17
typescript: 2.5.3
webpack: 3.10.0

Repro steps

  • Create a new project with ng new myproject
  • Run into the project directory and execute tests with ng test. All tests run successfully.
  • Edit the src/test.ts file and just move the line import 'zone.js/dist/zone-testing'; to be the last import.
  • Execute the tests again.

Observed behavior

All tests are failed with this error :

       TypeError: Cannot read property 'assertPresent' of undefined
            at resetFakeAsyncZone C:/work/intellij-workspace.d/angular/newcli1.6.8/node_modules/@angular/core/esm5/testing.js:367:1)
            at UserContext.<anonymous> C:/work/intellij-workspace.d/angular/newcli1.6.8/node_modules/@angular/core/esm5/testing.js:1254:1)
            at ZoneQueueRunner.webpackJsonp.../../../../zone.js/dist/zone-testing.js.jasmine.QueueRunner.ZoneQueueRunner.execute C:/work/intellij-workspace.d/angular/newcli1.6.8/node_modules/zone.js/dist/zone-testing.js:437:1)
Chrome 64.0.3282 (Windows 10.0.0): Executed 1 of 3 (1 FAILED) (0 secs / 0.103 secs)
Chrome 64.0.3282 (Windows 10.0.0) AppComponent should create the app FAILED
        TypeError: Cannot read property 'assertPresent' of undefined
            at resetFakeAsyncZone C:/work/intellij-workspace.d/angular/newcli1.6.8/node_modules/@angular/core/esm5/testing.js:367:1)
            at UserContext.<anonymous> C:/work/intellij-workspace.d/angular/newcli1.6.8/node_modules/@angular/core/esm5/testing.js:1254:1)
            at ZoneQueueRunner.webpackJsonp.../../../../zone.js/dist/zone-testing.js.jasmine.QueueRunner.ZoneQueueRunner

Desired behavior

All tests would run successfully. In fact, I had this error just because WebStorm automatically reorganized imports. So the zone.js import was moved after the @angular ones.
Is this behavior normal?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions