1

After upgrading from Angular 13 to 14 I am having issues with my unit tests, using ng-bullet. Only the first test of each test spec is passing with the remaining tests failing. There is a deprecation warning which ng-bullet seems to violate:

"An asynchronous before/it/after function took a done callback but also returned a promise. This is not supported and will stop working in the future. Either remove the done callback (recommended) or change the function to not return a promise."

I assume that this piece of code in the ng-bullet source code is violating the deprecation warning:

if (configureAction) {
        beforeAll((done: DoneFn) => (async () => {
            configureAction();
            await TestBed.compileComponents();
        })().then(done).catch(done.fail));
    }

While upgrading to Angular 14 I have not changed any versions for Karma or Jasmine so I made the assumption that it should not break. Why does it still break although I have not changed the testing libraries versions? I am using karma 6.4.0, jasmine core 3.8.0 and karma-jasmine 4.0.1.

Is there any workaround?

Thank you.

dnyn
  • 51
  • 4

1 Answers1

1

Had the same issue a while back. Your best bet is to stop using ng-bullet. Instead, use beforeEach or beforeAll depending on your usecase.

In my experience, it doesn't speed up your tests that much to justify using it. Jasmine tests have gotten faster over the years. And as well, the package it's not been actively maintained - hasn't been updated in 4 years.

Also, have a read at this issue that goes more indepth about what your seeing.

laudebugs
  • 166
  • 1
  • 4
  • Thanks for your response! We also tried to remove ng-bullet to check the speed but it took much longer to run through all the tests since we have thousands. – dnyn Sep 02 '22 at 10:49
  • @dnyn did you ever find a solution to this? We are running into the same thing. – Techgeekster Nov 02 '22 at 04:59
  • No, unfortunately not. We have migrated to ngneat spectator (recommendation of ng-bullet author -https://medium.com/angular-in-depth/angular-unit-testing-performance-34363b7345ba). But running our tests are taking much longer (3-4x). We are considering to move to Jest – dnyn Nov 04 '22 at 07:36