Trouble Setting Up Jest with Ionic 6 and Angular 14

Hello community,

I’m currently working on a project using Ionic 6 with Angular 14, and I’m trying to set up Jest for unit testing. However, I’m encountering some challenges in the process. I’ve followed the official documentation, but it seems like there might be version-specific considerations.

Here are the steps I’ve taken so far:

  1. Installed Jest and required dependencies.
  2. Configured Jest in the jest.config.js file.
  3. Tried to run some sample tests, but I’m facing issues with module resolution and TypeScript compilation.

I’ve searched through the forums and online resources, but I haven’t found a solution that fits my scenario.

Has anyone successfully set up Jest with Ionic 6 and Angular 14 recently? If so, could you share your configuration or point me in the right direction? Any help would be greatly appreciated!

Thank you in advance.

This is My package.json

 "devDependencies": {
    "@angular-devkit/build-angular": "^14.2.10",
    "@angular/cli": "^14.2.10",
    "@angular/compiler": "^14.2.12",
    "@angular/compiler-cli": "^14.2.12",
    "@angular/language-service": "^14.2.12",
    "@ionic/angular-toolkit": "^4.0.0",
    "@types/node": "^12.11.1",
    "@typescript-eslint/eslint-plugin": "^5.54.0",
    "@typescript-eslint/parser": "^5.54.0",
    "cordova-launch-review": "^4.0.1",
    "cordova-open-native-settings": "^1.5.5",
    "cordova-plugin-androidx": "^3.0.0",
    "cordova-plugin-androidx-adapter": "^1.1.3",
    "cordova-plugin-device": "^2.0.2", ....
},
 "dependencies": {
    "@angular-eslint/schematics": "^1.0.0",
    "@angular/common": "^14.2.12",
    "@angular/core": "^14.2.12",
    "@angular/forms": "^14.2.12",
    "@angular/platform-browser": "^14.2.12",
    "@angular/platform-browser-dynamic": "^14.2.12",
    "@angular/router": "^14.2.12",
    "@awesome-cordova-plugins/adjust": "^6.3.0",
    "@awesome-cordova-plugins/core": "^6.3.0",
    "@awesome-cordova-plugins/deeplinks": "^6.4.0",
    "@awesome-cordova-plugins/device": "^6.3.0",
    "@awesome-cordova-plugins/fcm": "^6.4.0",
    "@awesome-cordova-plugins/firebase-analytics": "^6.3.0",
    "@awesome-cordova-plugins/geolocation": "^6.3.0",
    "@awesome-cordova-plugins/in-app-browser": "^6.4.0", ... . .}

anyone there for help me :face_exhaling:

Firstly, you should post your error message here for us to understand your situation.

Secondly, you should also post your babel.config.js here. You said you are facing a TypeScript-related issue, so there’s a possibility of having some issues with your configuration there. It would be better to post your jest.config.js here as well for further investigation.

Lastly, this forum is not very active, at least much more inactive than Stack Overflow. You may want to post your question there.