We upgraded our Angular application from version 16 to 18. After upgrade our unit tests are started failing with below error.
Error: NG0205: Injector has already been destroyed. in http://localhost:9876/_karma_webpack_/vendor.js (line 59623)
error properties: Object({ code: 205 })
assertNotDestroyed@http://localhost:9876/_karma_webpack_/vendor.js:62653:13
get@http://localhost:9876/_karma_webpack_/vendor.js:62545:10
get appRef@http://localhost:9876/_karma_webpack_/vendor.js:124410:43
findGroupContainer@http://localhost:9876/_karma_webpack_/vendor.js:124421:23
show@http://localhost:9876/_karma_webpack_/vendor.js:124381:25
setNotificationMessageAndTimeOut@http://localhost:9876/_karma_webpack_/main.js:1077:54
showDanger@http://localhost:9876/_karma_webpack_/main.js:1063:10
showErrorAlert@http://localhost:9876/_karma_webpack_/main.js:1443:27
3354/getData/<@http://localhost:9876/_karma_webpack_/main.js:1367:12
1318/catchError/</innerSub<@http://localhost:9876/_karma_webpack_/vendor.js:9619:88
1687/OperatorSubscriber/this._error<@http://localhost:9876/_karma_webpack_/vendor.js:9492:16
error@http://localhost:9876/_karma_webpack_/vendor.js:8530:12
_error@http://localhost:9876/_karma_webpack_/vendor.js:8553:24
error@http://localhost:9876/_karma_webpack_/vendor.js:8530:12
_error@http://localhost:9876/_karma_webpack_/vendor.js:8553:24
error@http://localhost:9876/_karma_webpack_/vendor.js:8530:12
_error@http://localhost:9876/_karma_webpack_/vendor.js:8553:24
error@http://localhost:9876/_karma_webpack_/vendor.js:8530:12
_error@http://localhost:9876/_karma_webpack_/vendor.js:8553:24
error@http://localhost:9876/_karma_webpack_/vendor.js:8530:12
onLoad@http://localhost:9876/_karma_webpack_/vendor.js:25246:22
invokeTask@http://localhost:9876/_karma_webpack_/polyfills.js:456:171
onInvokeTask@http://localhost:9876/_karma_webpack_/vendor.js:13689:33
invokeTask@http://localhost:9876/_karma_webpack_/polyfills.js:456:54
runTask@http://localhost:9876/_karma_webpack_/polyfills.js:259:37
invokeTask@http://localhost:9876/_karma_webpack_/polyfills.js:533:26
invokeTask@http://localhost:9876/_karma_webpack_/polyfills.js:1150:12
globalCallback@http://localhost:9876/_karma_webpack_/polyfills.js:1191:33
globalZoneAwareCallback@http://localhost:9876/_karma_webpack_/polyfills.js:1211:12
If you guys have faced similar bug and know the resolution please let us know.
Thanks in advanced.