1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Angular Test Cases Jasmine

Discussão em 'Angular' iniciado por Nitin, Junho 6, 2025.

  1. Nitin

    Nitin Guest

    I am trying to write test cases for this Super Report Component where I provided all the required services and routers, and when I execute my test cases, I will not get any results: no success or error messages.

    For example, here I get this message Executed 0 of 285 DISCONNECTED:

    describe('SuperReportsComponent', () => {
    let component: SuperReportsComponent;
    let navigationService: NavigationService;
    let appService: AppService;
    let reportService: ReportsService;
    let reportAction = ReportActions;
    let router: Router;
    let route: ActivatedRoute;
    let store: Store<AppState>;
    let fixture: ComponentFixture<SuperReportsComponent>;

    const MockRouter = {
    navigate: jasmine.createSpy('navigate')
    };

    const MockActivatedRoute = {};

    beforeEach(async(() => {
    TestBed.configureTestingModule({
    declarations: [SuperReportsComponent],
    imports: [NgCircleProgressModule.forRoot({}),
    NgbPopoverModule,
    HeaderModule,
    StoreModule.forRoot(rootReducer),
    HttpModule,
    CommonModule,
    FormsModule,
    NgbModule.forRoot()],
    providers: [
    ReportActions,
    AppService,
    ReportsService,
    NavigationService,
    NotificationService,
    WebsocketService,
    SharedLayoutService,
    SuperdashService,
    {provide: Router, useValue: MockRouter},
    {provide: ActivatedRoute, useValue: MockActivatedRoute}
    ]
    })
    .compileComponents();
    }));

    beforeEach(() => {
    route = TestBed.get(ActivatedRoute);
    router = TestBed.get(Router);
    navigationService = TestBed.get(NavigationService);
    appService = TestBed.get(AppService);
    reportService = TestBed.get(ReportsService);
    reportAction = TestBed.get(ReportActions);
    store = TestBed.get(Store);
    fixture = TestBed.createComponent(SuperReportsComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
    });

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


    Here I mock the navigate method and provide all the services with its required modules, but I didn't get any output.

    OUTPUT:

    Chrome 69.0.3497 (Linux 0.0.0) ERROR
    Chrome 69.0.3497 (Linux 0.0.0) ERROR
    Disconnected, because no message in 10000 ms.
    Chrome 69.0.3497 (Linux 0.0.0): Executed 0 of 285 DISCONNECTED (10 secs / 0 secs)


    How can I solve this problem?

    Continue reading...

Compartilhe esta Página