Getting error as ` TypeError: t.factory is not a function` on running jest with angular

Viewed 702

I am integrated the jest with angular. while i run i am getting an error as :

  ● Test suite failed to run

    TypeError: t.factory is not a function

      at node_modules/ts-jest/dist/config/config-set.js:409:74
          at Array.map (<anonymous>)
      at ConfigSet.get (node_modules/ts-jest/dist/config/config-set.js:409:46)
      at ConfigSet.tsCustomTransformers (node_modules/ts-jest/dist/util/memoize.js:43:24)
      at Object.getCustomTransformers (node_modules/ts-jest/dist/compiler/language-service.js:115:61)
      at Object.getEmitOutput (node_modules/typescript/lib/typescript.js:136021:73)
      at compileFn (node_modules/ts-jest/dist/compiler/language-service.js:123:34)
      at Object.compile (node_modules/ts-jest/dist/compiler/instance.js:52:21)
      at TsJestTransformer.process (node_modules/ts-jest/dist/ts-jest-transformer.js:85:41)
      at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:463:35)

Not able to understand the issue. any one help me? here is my package.json file

{
  "name": "ibo",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "jest",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "build:single-spa:ibo": "ng build ibo --prod --deploy-url http://localhost:4200/",
    "serve:single-spa:ibo": "ng s --project ibo  --port 3000 --deploy-url http://localhost:3000/ --live-reload true"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~9.1.7",
    "@angular/common": "~9.1.7",
    "@angular/compiler": "~9.1.7",
    "@angular/core": "~9.1.7",
    "@angular/forms": "~9.1.7",
    "@angular/platform-browser": "~9.1.7",
    "@angular/platform-browser-dynamic": "~9.1.7",
    "@angular/router": "~9.1.7",
    "@ibo/ibo-shared-lib": "0.0.61",
    "@ngrx/data": "^9.1.2",
    "@ngrx/effects": "^9.1.2",
    "@ngrx/router-store": "^9.1.2",
    "@ngrx/store": "^9.1.2",
    "@ngrx/store-devtools": "^9.1.2",
    "@ngx-translate/core": "^12.1.2",
    "@ngx-translate/http-loader": "^4.0.0",
    "@types/jest": "^25.2.3",
    "date-fns": "^2.14.0",
    "jest": "^26.0.1",
    "jest-preset-angular": "^8.2.0",
    "js-datepicker": "^5.13.0",
    "jspdf": "^1.5.3",
    "microsoft-adal-angular6": "^1.3.0",
    "ng-pick-datetime": "^7.0.0",
    "ng2-file-upload": "^1.4.0",
    "ngx-contextmenu": "^5.4.0",
    "ngx-quill": "^11.0.0",
    "node-sass": "^4.14.1",
    "popper.js": "^1.16.1",
    "quill": "^1.3.7",
    "rxjs": "~6.5.4",
    "single-spa": "^5.5.1",
    "single-spa-angular": "^4.1.0",
    "ts-jest": "^26.0.0",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-builders/custom-webpack": "^9.1.0",
    "@angular-devkit/build-angular": "~0.901.6",
    "@angular/cli": "~9.1.6",
    "@angular/compiler-cli": "~9.1.7",
    "@ngrx/schematics": "^9.1.2",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "protractor": "~5.4.3",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.8.3"
  },
  "jest": {
    "preset": "jest-preset-angular",
    "testMatch": [
      "<rootDir>/src/**/*.spec.ts"
    ],
    "setupFilesAfterEnv": [
      "<rootDir>/setupJest.ts"
    ],
    "testPathIgnorePatterns": [
      "<rootDir>/node_modules/",
      "<rootDir>/dist/"
    ],
    "transform": {
      "^.+\\.(ts|js|html)$": "ts-jest"
    },
    "globals": {
      "ts-jest": {
        "tsConfig": "<rootDir>/tsconfig.spec.json",
        "stringifyContentPathRegex": "\\.html$",
        "astTransformers": [
          "jest-preset-angular/build/AngularSnapshotSerializer.js",
          "jest-preset-angular/build/HTMLCommentSerializer.js"
        ]
      }
    }
  }
}

setupJest.ts :

import 'jest';
import 'jest-preset-angular';
0 Answers
Related