'Angular + karma tests failing intermittently

I recently upgraded our project's application version from 9 to 13 and as a part of it also upgraded few packages used including chromedriver, node, karma etc. Now we are using node v16 and angular v13 and karma v6.3.11.

I have karma.conf.js setup with concurrency Infinity and I see that specific unit test fail every time I run it because of following error. When I run it individually using "fit" it passes every time I run it. Any suggestions?

Error details :

TypeError: Cannot set properties of undefined (setting 'src')
     at VgMediaDirective.ngOnDestroy (node_modules/@videogular/ngx-videogular/fesm2015/videogular-ngx-videogular-core.mjs:959:1)


Solution 1:[1]

It seems the error is coming from @videogular npm package.

Do you have version 5.0.1 of @videogular installed?

If not, install that version to see if the error goes away.

If the error does not go away, I would mock the directive instead of providing the real one in the unit tests.

Check out mocking directives here: https://stackoverflow.com/a/57099227/7365461

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 AliF50