I am getting the below error when i run npm test we have used jest for unit test coverage.
Test suite failed to run AngularJS v1.x is not loaded!
at Object.noNg (../../../packages/upgrade/src/common/src/angular1.ts:228:9)
at node_modules/@uirouter/angular-hybrid/bundles/ng:/@uirouter/angular-hybrid/angular-hybrid.ts:51:38
at node_modules/@uirouter/angular-hybrid/bundles/uirouter-angular-hybrid.umd.js:2:68
at Object.<anonymous> (node_modules/@uirouter/angular-hybrid/bundles/uirouter-angular-hybrid.umd.js:5:2)
at Object.<anonymous> (src/customer-forms/customer-forms.routing.module.ts:2:1)
at Object.<anonymous> (src/customer-forms/index.ts:6:1)
at Object.<anonymous> (src/core/effects/library.effects.ts:25:1)
at Object.<anonymous> (src/core/effects/index.ts:1:1)
at Object.<anonymous> (src/core/index.ts:41:1)
at Object.<anonymous> (src/selectors/print-queue.selectors.ts:3:1)
at Object.<anonymous> (src/selectors/index.ts:7:1)
at Object.<anonymous> (src/shared/directives/order-by.directive.ts:13:1)
at Object.<anonymous> (src/shared/directives/index.ts:2:1)
at Object.<anonymous> (src/shared/shared.module.ts:4:1)
at Object.<anonymous> (src/shared/index.ts:1:1)
at Object.<anonymous> (test/effects/common.effects.test.ts:4:1)
Any one has idea on this please help.
It has both angulajs and angular9 upgrade code base
Jest configuration
"@types/jest": "24.0.6",
"bamboo-jest-reporter": "1.0.3",
"jest": "24.9.0",
"jest-junit": "10.0.0",
"ts-jest": "24.1.0"
The above versions are listed in package.json. it is working in angularjs+angular7 solution after upgrade to 9 or 10 versions i am getting the above mentioned issue.
Issue got fixed This issue is coming because of the paths of the services imports. We have imported service directly from the paths like bellow
import { WorkPermitsService } from '../../work-permits/work-permits.service';
After upgrading to angular 9 imported paths are not resolved when I run the unit tests. So i have exported it in services index.ts and importing from @services (common place for exporting) where ever required. like this i have done for all.
Change :
export { WorkPermitsService } from '../../work-permits/work-permits.service';
Importing in required places
import { WorkPermitsService} from '@services';