mwootendev / ngx-translate-plugins

Utilities plugins for the @ngx-translate translation library.
MIT License
16 stars 10 forks source link

Not working with Angular 12 Jest #64

Open rahulh11041996 opened 2 years ago

rahulh11041996 commented 2 years ago

Class constructor TranslateLoader cannot be invoked without 'new' --- error is showing while running jest test in angular 12, please someone help me.

"devDependencies": { "@angular-devkit/build-angular": "~12.0.0", "@angular/cli": "~12.0.0", "@angular/compiler-cli": "~12.0.0", "@fullhuman/postcss-purgecss": "^5.0.0", "@types/jest": "^29.2.0", "@types/node": "^12.11.1", "cssnano": "^5.1.13", "jest": "^29.2.1", "jest-preset-angular": "^12.2.2", "jscat": "0.0.2", "ngx-translate-testing": "^5.2.0", "postcss": "^8.4.17", "postcss-loader": "^7.0.1", "postcss-preset-env": "^7.8.2", "postcss-scss": "^4.0.5", "sass": "^1.55.0", "typescript": "~4.2.3" }

Error log:

TypeError: Class constructor TranslateLoader cannot be invoked without 'new'

  at new TestTranslateLoader (projects/testing/src/lib/test-translate-loader.service.ts:23:5)
  at TranslateTestingModule.get (projects/testing/src/lib/testing.module.ts:95:7)
  at R3Injector.Object.<anonymous>.R3Injector.processInjectorType (../packages/core/src/di/r3_injector.ts:366:61)
  at ../packages/core/src/di/r3_injector.ts:326:20
  at ../packages/core/src/util/array_utils.ts:71:74
      at Array.forEach (<anonymous>)
  at deepForEach (../packages/core/src/util/array_utils.ts:71:9)
  at ../packages/core/src/util/array_utils.ts:71:49
      at Array.forEach (<anonymous>)
  at deepForEach (../packages/core/src/util/array_utils.ts:71:9)
  at ../packages/core/src/util/array_utils.ts:71:49
      at Array.forEach (<anonymous>)
  at deepForEach (../packages/core/src/util/array_utils.ts:71:9)
  at R3Injector.Object.<anonymous>.R3Injector.processInjectorType (../packages/core/src/di/r3_injector.ts:325:9)
  at ../packages/core/src/di/r3_injector.ts:147:44
  at ../packages/core/src/util/array_utils.ts:71:74
      at Array.forEach (<anonymous>)
  at deepForEach (../packages/core/src/util/array_utils.ts:71:9)
  at new R3Injector (../packages/core/src/di/r3_injector.ts:147:5)
  at createInjectorWithoutInjectorInstances (../packages/core/src/di/r3_injector.ts:97:10)
  at new NgModuleRef$1 (../packages/core/src/render3/ng_module_ref.ts:54:24)
  at R3TestBedCompiler.Object.<anonymous>.R3TestBedCompiler.finalize (../packages/core/testing/src/r3_test_bed_compiler.ts:260:26)
  at TestBedRender3.get (../packages/core/testing/src/r3_test_bed.ts:370:43)
  at TestBedRender3.Object.<anonymous>.TestBedRender3.inject (../packages/core/testing/src/r3_test_bed.ts:268:25)
  at TestBedRender3.Object.<anonymous>.TestBedRender3.createComponent (../packages/core/testing/src/r3_test_bed.ts:325:40)
  at Function.Object.<anonymous>.TestBedRender3.createComponent (../packages/core/testing/src/r3_test_bed.ts:177:33)
  at src/app/shared/components/translate/translate.component.spec.ts:23:23
  at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:409:30)
  at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:3830:43)
  at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:408:56)
  at Zone.Object.<anonymous>.Zone.run (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:169:47)
  at Object.wrappedFunc (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:4330:34)