angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Getting Errors on ng test command ( KARMA - JASMINE unit tests)

Open hardeep-bit opened this issue 8 years ago • 2 comments

Versions

   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.1.0
node: 7.10.1
os: linux x64
@angular/animations: 4.4.6
@angular/common: 4.4.6
@angular/compiler: 4.4.6
@angular/core: 4.4.6
@angular/forms: 4.4.6
@angular/http: 4.4.6
@angular/platform-browser: 4.4.6
@angular/platform-browser-dynamic: 4.4.6
@angular/router: 4.4.6
@angular/service-worker: 1.0.0-beta.16
@angular/cli: 1.1.0
@angular/compiler-cli: 4.4.6
@angular/language-service: 4.4.6
@angular/platform-server: 4.4.6

In my Application i was integrating Angular cli as first it was not there ! Want to test my Application with karma - jasmine. when i run command ng test then i get the ERRORS -

Observed behavior

ERROR in /repo/node_modules/@angular/core/src/di/reflective_provider.d.ts (87,123): Cannot find name 'Map'.

ERROR in /repo/node_modules/@angular/core/src/di/reflective_provider.d.ts (87,165): Cannot find name 'Map'.

ERROR in /repo/node_modules/rxjs/Observable.d.ts (58,60): 'Promise' only refers to a type, but is being used as a value here.

ERROR in /repo/node_modules/rxjs/Observable.d.ts (73,59): 'Promise' only refers to a type, but is being used as a value here.

ERROR in /repo/node_modules/@angular/core/src/change_detection/differs/iterable_differs.d.ts (15,48): Cannot find name 'Iterable'.

ERROR in /repo/node_modules/@angular/core/src/change_detection/differs/keyvalue_differs.d.ts (23,18): Cannot find name 'Map'.

ERROR in /repo/node_modules/@angular/core/src/change_detection/differs/default_iterable_differ.d.ts (28,32): Cannot find name 'Iterable'.

ERROR in /repo/node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts (24,16): Cannot find name 'Map'.

ERROR in /repo/node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts (32,16): Cannot find name 'Map'.

ERROR in /repo/src/client/app/iterm-extended/component/get-a-quote.component.ts (32,14): Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.

Desired behavior

Want to see on browser for UNIT TESTING. Because of these errors i can't Test. Please help. !! Even on stackoverflow i did not find any thing related to these ERRORS.

tsconfig.json

{
  "compilerOptions": {
    // "module": "es2015",
    "moduleResolution": "node",
    "target": "es5",
    "noImplicitAny": false,
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es2017",
      "dom"
    ],
    "typeRoots": [
      "node_modules/@types"
    ],
    "skipLibCheck": true
  },
  "include": [
    "src/client/**/*.ts"
  ],
  "exclude": [
    "node_modules",
    "src/client/main-prod.ts"
  ],
  "compileOnSave": false
}

karma.config.js

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular/cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular/cli/plugins/karma')
    ],
    files: [
      "src/client/test-cases/iterm-extended/**/*.spec.ts",
      { pattern: 'node_modules/**', included: false, watched: false },
      { pattern: 'src/client/app/iinvest/**', included: false, watched: false },
      { pattern: 'src/client/app/imax/**', included: false, watched: false },
      { pattern: 'src/client/app/iterm/**', included: false, watched: false },
      { pattern: 'src/client/app/itermPlus-extended/**', included: false, watched: false },
      { pattern: 'src/client/app/pages/**', included: false, watched: false },
      { pattern: 'src/client/app/shared/**', included: false, watched: false }
    ],
    client: {
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      reports: ['html', 'lcovonly'],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};

hardeep-bit avatar Apr 04 '18 07:04 hardeep-bit

For support requests, I'd recommend you to use the Angular channel at gitter or StackOverflow. Let us close this issue for now.

mgechev avatar Dec 26 '18 19:12 mgechev

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.