Test unable to run test cases exits with TypeError: Jest: a transform must export a `process` function

  angular, jestjs

{ //tsconfig.base.json
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"typeRoots": ["node_modules/@types"],
"lib": ["es2018", "dom"] },
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}

    //ts.spec.json
   {
  "extends": "./tsconfig.base.json",
  "compilerOptions": {
    "outDir": "./out-tsc/spec",
    "types": ["jest", "node"],
    "esModuleInterop": true,
    "emitDecoratorMetadata": true
  },
  "files": ["src/test.ts", "src/polyfills.ts"],
  "include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
   }


//setupTest.js
import 'jest-extended';
import 'jest-preset-angular/setup-jest';
import './globalMocks';




 //jest dependancies list 
"@types/jest": "~26.0.15",
    "@types/node": "^12.11.1",
    "@types/uuid": "^7.0.0",
    "babel-jest": "^27.0.2",
    "codelyzer": "^6.0.0",
    "jest": "^26.6.3",
    "jest-environment-jsdom-sixteen": "1.0.3",
    "jest-extended": "^0.11.5",
    "jest-junit": "^12.0.0",
    "jest-preset-angular": "^9.0.0-next.3",
    "ng-bullet": "~1.0.3",
    "regenerator-runtime": "^0.13.7",
    "rxjs-tslint-rules": "^4.34.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~4.0.5"




FAIL  src/app/authentication/register/register.component.spec.ts
  ● Test suite failed to run

    TypeError: Jest: a transform must export a `process` function.

      at ScriptTransformer._getTransformer (node_modules/@jest/transform/build/ScriptTransformer.js:360:13)
      at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:427:28)
      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:569:40)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:607:25)

Source: Angular Questions

One Reply to “Test unable to run test cases exits with TypeError: Jest: a transform must export a `process` function”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.