0

I have a test folder in which there are 3 files,

1)nav-bar.init.spec.ts
2)nav-bar.scaffold.ts
3)nav-bar.spec.ts

I have the following codes respectively,

In nav-bar.init.spec.ts,

       import { TestBed, async } from '@angular/core/testing';
       import { Navbarcomponent } from './app.component';
        describe('Navbarcomponent', () => {
          beforeEach(async(() => {
                TestBed.configureTestingModule({
              declarations: [
             Navbarcomponent
                ],
              }).compileComponents();
              }));

In nav-bar.spec.ts,

       import { TestBed, async } from'@angular/core/testing';
       import { Navbarcomponent } from './app.component';
        describe('Navbarcomponent', () => {
           let component: Navbarcomponent;
          beforeEach(() => {
                  component = new Navbarcomponent();
           }));
        it (should create,()=>{
            expect(conponent).toBeTruthy()
        });                 //// I added this test case here

When I run the test cases,the karma screen shows 'NO SPEC FOUND'

My Karma.config file, karma-config-1

 [karma-config-2][2]

I am confused with this modularity. Can anyone please suggest me help.Thanks.

learner
  • 357
  • 1
  • 6
  • 16

1 Answers1

0

Based off a quick look, I think the issue is that you haven't configured your testbed properly:

import { ComponentFixture, TestBed } from '@angular/core/testing';

describe('AppComponent', () => {
  let component: AppComponent;
  let fixture: ComponentFixture<AppComponent>;

TestBed.configureTestingModule({
      schemas: [NO_ERRORS_SCHEMA],
      declarations: [AppComponent],
      providers: [
        { provide: Router, useValue: routerStub },
        { provide: ActivatedRoute, useValue: activatedRouteStub },
        { provide: I18nService, useValue: i18nServiceStub },
        { provide: PlatformLocation, useValue: platformLocationStub },
        ...
      ]
    });

    fixture = TestBed.createComponent(AppComponent);
    component = fixture.componentInstance;
});
Anton Bks
  • 482
  • 3
  • 10