jQWidgets Forums

Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts

  • caseybelcher543
    Participant

    Martin, for unit testing should the karma.conf.js also fill the “include” and “files” fields in the same way? I have another question posted in this forum with a simple starter Angular 6 project where I can “ng serve” but not “ng test”.


    caseybelcher543
    Participant

    I will make this simpler: I have made a new angular project which does nothing other than load a single jqxGrid:

    app.component.spec.ts :

    
    import { TestBed, async, ComponentFixture } from '@angular/core/testing';
    import { AppComponent } from './app.component';
    import { jqxGridComponent } from 'jqwidgets-scripts/jqwidgets-ts/angular_jqxgrid';
    
    describe('AppComponent', () => {
      let component: AppComponent; 
      let fixture: ComponentFixture<AppComponent>; 
    
      beforeEach(async(() => {
        TestBed.configureTestingModule({
          declarations: [jqxGridComponent, AppComponent]
        }).compileComponents();
      }));
    
      beforeEach(() => { 
        fixture = TestBed.createComponent(AppComponent); 
        component = fixture.componentInstance; 
      })
    
      it('app dummy test', () => {
        expect(1).toBe(2);
      });
    });
    
    

    app.component.ts :

    
    import { Component } from '@angular/core';
    import { jqxGridComponent } from 'jqwidgets-scripts/jqwidgets-ts/angular_jqxgrid';
    
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
    })
    export class AppComponent {
      constructor() {}
    }
    
    

    app.modules.ts :

    
    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    import { AppComponent } from './app.component';
    
    import { jqxGridComponent } from 'jqwidgets-scripts/jqwidgets-ts/angular_jqxgrid';
    
    @NgModule({
      declarations: [AppComponent, jqxGridComponent],
      imports: [BrowserModule],
      providers: [], 
      bootstrap: [AppComponent] 
    })
    export class AppModule {}    
    

    Same behavior as before.


    caseybelcher543
    Participant

    Hello mohanarao, I have a question posted related to jqx testing as well. Could you post your entire .spec file? Also your karma.conf.js file? What kind of unit test error were you getting?


    caseybelcher543
    Participant

    Also, when first running “ng test” I get the “missing from Typescript compilation” error that others have complained about. When ng serving this is fixed by all the tsconfig changes mentioned here:

    https://www.jqwidgets.com/angular-components-documentation/documentation/create-jqwidgets-angular-app/index.htm?search=test

    When I edit and re-save app.module.ts, the tests try to build themselves again – but this time I get

    Uncaught ReferenceError: Zone is not defined at http://localhost:9876/

    It is only after I edit and re-save app.module.ts again (and sometimes multiple times after that – with same “Zone is not defined” problem) that the tests will run – but with the problem in original post.


    caseybelcher543
    Participant

    I should also note that using a mock grid within the declarations array works – so I do believe this is something jqx related.

Viewing 5 posts - 1 through 5 (of 5 total)