title: How to unit test Ionic 3 apps
body: <p>I would like to unit test my ionic 3 app. </p>
  
  <p>I am unable to run below commands
  npm test, ng test etc. I have installed angular cli also but unbale to run the test commands.</p>
  
  <p>Below is my package.json</p>
  
  <pre><code>    {
      "name": "XYZ",
      "version": "0.0.1",
      "author": "Ionic Framework",
      "homepage": "http://ionicframework.com/",
      "private": true,
      "scripts": {
          "clean": "ionic-app-scripts clean",
          "build": "ionic-app-scripts build",
          "lint": "ionic-app-scripts lint",
          "ionic:build": "ionic-app-scripts build",
          "ionic:serve": "ionic-app-scripts serve",
          "test": "ng test"
      },
      "dependencies": {
          "@angular/animations": "^5.2.11",
          "@angular/common": "5.2.11",
          "@angular/compiler": "5.2.11",
          "@angular/compiler-cli": "5.2.11",
          "@angular/core": "5.2.11",
          "@angular/forms": "5.2.11",
          "@angular/http": "5.2.11",
          "@angular/platform-browser": "5.2.11",
          "@angular/platform-browser-dynamic": "5.2.11",
          "@angular/router": "^4.3.5",
          "@ionic-native/android-permissions": "^4.11.0",
          "@ionic-native/calendar": "^4.17.0",
          "@ionic-native/call-number": "^4.17.0",
          "@ionic-native/camera": "^4.17.0",
          "@ionic-native/core": "^4.17.0",
          "@ionic-native/date-picker": "^4.20.0",
          "@ionic-native/device": "^4.18.0",
          "@ionic-native/email-composer": "^4.20.0",
          "@ionic-native/file": "^4.11.0",
          "@ionic-native/file-transfer": "^4.7.0",
          "@ionic-native/geolocation": "^4.17.0",
          "@ionic-native/google-maps": "^4.15.1",
          "@ionic-native/http": "^4.20.0",
          "@ionic-native/keyboard": "^4.11.0",
          "@ionic-native/native-geocoder": "^4.17.0",
          "@ionic-native/network": "^4.11.0",
          "@ionic-native/splash-screen": "4.7.0",
          "@ionic-native/sqlite": "^4.7.0",
          "@ionic-native/status-bar": "^4.12.1",
          "@ionic-native/text-to-speech": "^4.20.0",
          "@ionic-native/toast": "^4.11.0",
          "@ionic-native/transfer": "^3.14.0",
          "@ionic/storage": "2.1.3",
          "@ngx-translate/core": "^9.1.1",
          "@ngx-translate/http-loader": "^3.0.1",
          "@swimlane/ngx-charts": "^7.3.0",
          "@types/jspdf": "^1.2.1",
          "angular-progress-bar": "^1.0.8",
          "angular-svg-round-progressbar": "^2.0.0",
          "angular-translate": "^2.18.1",
          "angular-translator": "^2.4.2",
          "angular2-signature-pad": "^1.0.2",
          "angular2-signaturepad": "^2.8.0",
          "angular2-text-mask": "^9.0.0",
          "calendar": "^0.1.0",
          "call-number": "^1.0.1",
          "cordova-android": "7.0.0",
          "cordova-browser": "5.0.4",
          "cordova-pdf-generator": "^2.0.8",
          "cordova-plugin-advanced-http": "2.0.8",
          "cordova-plugin-android-permissions": "^1.0.0",
          "cordova-plugin-calendar": "^5.1.4",
          "cordova-plugin-camera": "^4.0.3",
          "cordova-plugin-compat": "^1.2.0",
          "cordova-plugin-datepicker": "^0.9.3",
          "cordova-plugin-device": "^2.0.2",
          "cordova-plugin-email-composer": "^0.9.2",
          "cordova-plugin-exit": "^1.0.2",
          "cordova-plugin-file": "^6.0.1",
          "cordova-plugin-file-transfer": "^1.7.1",
          "cordova-plugin-geolocation": "^4.0.1",
          "cordova-plugin-googlemaps": "^2.5.2",
          "cordova-plugin-ionic-keyboard": "^2.1.3",
          "cordova-plugin-ionic-webview": "^1.2.1",
          "cordova-plugin-iroot": "0.8.0",
          "cordova-plugin-nativegeocoder": "^3.1.3",
          "cordova-plugin-network-information": "^2.0.1",
          "cordova-plugin-root-detection": "^0.1.1",
          "cordova-plugin-splashscreen": "^5.0.2",
          "cordova-plugin-sslcertificatechecker": "6.0.0",
          "cordova-plugin-statusbar": "^2.4.2",
          "cordova-plugin-tts": "^0.2.3",
          "cordova-plugin-whitelist": "^1.3.3",
          "cordova-plugin-x-toast": "^2.7.2",
          "cordova-sqlcipher-adapter": "^0.4.0",
          "cordova-sqlite-storage": "^3.2.0",
          "cordova-uglify": "^0.3.3",
          "crypto-js": "^3.1.9-1",
          "html2canvas": "^1.0.0-alpha.12",
          "ionic-angular": "3.9.2",
          "ionic-select-searchable": "^2.10.0",
          "ionicons": "3.0.0",
          "jspdf": "^1.4.1",
          "moment": "^2.22.2",
          "mx.ferreyra.callnumber": "0.0.2",
          "ng2-bootstrap-modal": "^1.0.1",
          "ng2-currency-mask": "^5.3.1",
          "ngx-filter-pipe": "^2.1.0",
          "rasterizehtml": "^1.3.0",
          "run": "1.4.0",
          "rxjs": "5.5.11",
          "sw-toolbox": "3.6.0",
          "ts-md5": "^1.2.4",
          "uglify-es": "github:mishoo/UglifyJS2#harmony",
          "uglify-js": "^3.5.11",
          "zone.js": "0.8.26"
      },
      "devDependencies": {
          "@ionic/app-scripts": "3.1.10",
          "@types/jasmine": "^3.4.6",
          "javascript-obfuscator": "^0.18.1",
          "typescript": "~2.6.2"
      },
      "description": "An Ionic project",
      "cordova": {
          "plugins": {
          "cordova-plugin-device": {},
          "cordova-plugin-splashscreen": {},
          "cordova-plugin-ionic-webview": {},
          "cordova-plugin-ionic-keyboard": {},
          "cordova-plugin-whitelist": {},
          "cordova-plugin-x-toast": {},
          "cordova-plugin-network-information": {},
          "cordova-plugin-file-transfer": {},
          "cordova-plugin-android-permissions": {},
          "cordova-plugin-statusbar": {},
          "cordova-pdf-generator": {},
          "cordova-plugin-nativegeocoder": {},
          "cordova-plugin-camera": {},
          "mx.ferreyra.callnumber": {},
          "cordova-plugin-googlemaps": {
              "API_KEY_FOR_ANDROID": "AIzaSyAnaUfH593PQAmbmyFqv9ow3FKLfx4rXc",
              "API_KEY_FOR_IOS": "AIzaSyA-naUfH593PQAmbmyFqv9ow3FKLfx4rXc",
              "PLAY_SERVICES_VERSION": "15.0.1",
              "ANDROID_SUPPORT_V4_VERSION": "27.+"
          },
          "cordova-plugin-calendar": {},
          "cordova-plugin-datepicker": {},
          "cordova-plugin-tts": {},
          "cordova-plugin-geolocation": {
              "GEOLOCATION_USAGE_DESCRIPTION": "To locate you"
          },
          "call-number": {},
          "cordova-plugin-advanced-http": {},
          "cordova-plugin-iroot": {
              "ENABLE_BUSYBOX_CHECK": "true"
          },
          "cordova-plugin-sslcertificatechecker": {},
          "cordova-sqlcipher-adapter": {},
          "cordova-sqlite-storage": {}
          },
          "config": {
          "ionic_cleancss": "./config/cleancss.config.js"
          },
          "platforms": [
          "android",
          "browser"
          ]
      }
      }
  </code></pre>
  
  <p>If I run command like npm test on cpommand prompt (ag=fter installing angular-cli) I get below error</p>
  
  <p>The test command requires to be run in an Angular project, but a project definition could not be found ionic.</p>
  
  <p>Since my project has been build as ionic-angular it does not have angular.json file which I feel is the reason it is not detecting the ng test/npm test commands.</p>
  
  <p>Please help.Thanks.</p>
  
  <p>Edit:</p>
  
  <p>Below is the error I am getting</p>
  
  <p><a href="https://i.stack.imgur.com/9muYs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9muYs.png" alt="error"></a></p>