Search code examples
angularkarma-jasmineangular15

Error during loading: Uncaught Error: describe with no children


What I do wrong?

I have one file with test - strategy.spec.ts

import { StrategyComponent } from './strategy.component';

describe(' get true number ', () => {
  let strategy: StrategyComponent;
});

file karma.conf.js

module.exports = function (config) {
  config.set({
    basePath: "../..",
    frameworks: ["jasmine"],
  });
};

I get error in karma-localhost (url - http://localhost:9876/)

0 specs, 1 failure, randomized with seed 93967

Error during loading: Uncaught Error: describe with no children
(describe() or it()): get true number in 
http://localhost:9876/base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?5a831622ecb7c749ca96e36d473ee583ebf6298b 
line 10042

Solution

  • if i write so template-test, I don't get error

    describe('TtestComponent', () => {
      let component: StrategyComponent;
      let fixture: ComponentFixture<StrategyComponent>;
    
      beforeEach(async () => {
        await TestBed.configureTestingModule({
          declarations: [StrategyComponent],
          imports: [TooltipComponent],
        }).compileComponents();
    
        fixture = TestBed.createComponent(StrategyComponent);
        component = fixture.componentInstance;
        fixture.detectChanges();
      });
    
      it('should create', () => {
        expect(component).toBeTruthy();
      });
    });