Skip to content

ng test fails after updating to the latest angular cli #2454

@fkolar

Description

@fkolar

Today I finally updated my project to the latest (from webpack.2) but after I fixed all the compilation errors and some API got refactored. I can not run my test anymore.

I am getting this not really descriptive error:

ypeError: Cannot read property 'injector' of null
            at TestBed._createCompilerAndModule (webpack:///projects/updatedCLI/~/@angular/core/testing/test_bed.js:247:0 <- src/test.ts:6951:44)
            at TestBed.compileComponents (webpack:///projects/updatedCLI/~/@angular/core/testing/test_bed.js:201:0 <- src/test.ts:6905:31)
            at Function.TestBed.compileComponents (webpack:///projects/updatedCLI/~/@angular/core/testing/test_bed.js:106:45 <- src/test.ts:6810:67)
            at Object.<anonymous> (webpack:///projects/updatedCLI/src/app/shared/components/widgets/check-box/tests/check-box.component.spec.ts:22:16 <- src/test.ts:59574:28)
            at ZoneDelegate.invoke (webpack:///projects/updatedCLI/~/zone.js/dist/zone.js:203:0 <- src/test.ts:81201:28)
            at ProxyZoneSpec.onInvoke (webpack:///projects/updatedCLI/~/zone.js/dist/proxy.js:72:0 <- src/test.ts:65403:39)
            at ZoneDelegate.invoke (webpack:///projects/updatedCLI/~/zone.js/dist/zone.js:202:0 <- src/test.ts:81200:34)
            at Zone.run (webpack:///projects/updatedCLI/~/zone.js/dist/zone.js:96:0 <- src/test.ts:81094:43)
            at Object.<anonymous> (webpack:///projects/updatedCLI/~/zone.js/dist/jasmine-patch.js:91:27 <- src/test.ts:65139:50)



I tried get rid of all the custom modules, components to see where could be the problem and ended up with this simple test and even this one gives me this error


fdescribe('Describe checkbox  behavior' , () =>
{


    fit('It should should have non null formControl and existing group if standalone. plus name , label' , () =>
    {
        TestBed.configureTestingModule({
            declarations: [
                TestCBBasicBehaviorComponent
            ]
        });

        TestBed.compileComponents();
        let fixtureWrapper = TestBed.createComponent(TestCBBasicBehaviorComponent);
        fixtureWrapper.detectChanges();


    });



});

@Component({
    selector: 'wrapper-comp' ,
    // template: '<w-checkbox [value]="cbValue" [label]="cbLabel" [name]="cbName" (onClick)="onCBClick($event)"></w-checkbox>'
    template: '<input type="checkbox" name="aaa" value="asdf"/>'
})
export class TestCBBasicBehaviorComponent
{

}

ng --version

Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.16
node: 4.6.0
os: darwin x64

Any pointers if this is anguler cli issue of more latest final angular 2.000

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions