'Having problems with testing angular app / ERROR: 'DEPRECATION: describe with no children (describe() or it())

After runned my test with this artist-detail.spec.ts

import { HttpClientModule } from '@angular/common/http';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterModule } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';

import { ArtistDetailComponent } from './artist-detail.component';

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

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      imports: [
        RouterTestingModule,
        RouterModule,
        HttpClientModule
      ],
      declarations: [ ArtistDetailComponent ]
    })
    .compileComponents();
  });

  beforeEach(() => {
    fixture = TestBed.createComponent(ArtistDetailComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

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

I have got this output

27 04 2022 18:23:06.651:INFO [launcher]: Starting browser ChromeHeadless 27 04 2022 18:23:09.795:INFO [Chrome Headless 100.0.4896.127 (Linux x86_64)]: Connected on socket iATQ5FHffdjRWSTWAAAB with id 92608559 Chrome Headless 100.0.4896.127 (Linux x86_64) ERROR: 'DEPRECATION: describe with no children (describe() or it()) is deprecated and will be removed in a future version of Jasmine. Please either remove the describe or add children to it. Error: at at Env.jasmineEnv. [as describe] (http://localhost:9876/karma_webpack/webpack:/node_modules/zone.js/fesm2015/zone-testing.js:454:1) at at Object.4911 (http://localhost:9876/karma_webpack/webpack:/src/app/modules/artist/artist-detail/artist-detail.component.spec.ts:8:1) at webpack_require (http://localhost:9876/karma_webpack/webpack:/webpack/bootstrap:19:1) Note: This message will be shown only once. Set the verboseDeprecations config property to true to see every occurrence.' Chrome Headless 100.0.4896.127 (Linux x86_64) ERROR: 'DEPRECATION: describe with no children (describe() or it()) is deprecated and will be removed in a future version of Jasmine. Please either remove the describe or add children to it. Error: at at Env.jasmineEnv. [as describe] (http://localhost:9876/karma_webpack/webpack:/node_modules/zone.js/fesm2015/zone-testing.js:454:1) at at Object.4911 (http://localhost:9876/karma_webpack/webpack:/src/app/modules/artist/artist-detail/artist-detail.component.spec.ts:8:1) at webpack_require (http://localhost:9876/karma_webpack/webpack:/webpack/bootstrap:19:1) Note: This message will be shown only once. Set the verboseDeprecations config property to true to see every occurrence.' Chrome Headless 100.0.4896.127 (Linux x86_64) ERROR: 'DEPRECATION: describe with no children (describe() or it()) is deprecated and will be removed in a future version of Jasmine. Please either remove the describe or add children to it. Error: at at Env.jasmineEnv. [as describe] (http://localhost:9876/karma_webpack/webpack:/node_modules/zone.js/fesm2015/zone-testing.js:454:1) at at Object.4911 (http://localhost:9876/karma_webpack/webpack:/src/app/modules/artist/artist-detail/artist-detail.component.spec.ts:8:1) at webpack_require (http://localhost:9876/karma_webpack/webpack:/webpack/bootstrap:19:1) Note: This message will be shown only once. Set the verboseDeprecations config property to true to see every occurrence.' ExhibitionDetailComponent ✔ should create

How can I fix the issue ERROR: 'DEPRECATION'
Thanks a lot



Solution 1:[1]

The above deprecation warning does not tell you which test has the problem. It is just like a summary warning saying that one of the test(s) have this problem.

To found out which tests need to be fixed please add verboseDeprecations: true for jasmine in karma.conf.js config file (see below)

    client: {
      jasmine: {
        ....
        verboseDeprecations: true,
        ...
      },
      ...
    },

Then run all or required unit tests and see the name of each of the tests that has describe with no children problem and fix those (add children or remove those describe).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1