Getting errors when testing a command (KARMA - JASMINE)

In my application, I integrated Angular cli, because at first it was not there!

I want to test my application with karma and jasmine.

When I run the command ng test, I get errors:

package.json:

@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

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

I want to see ONE TEST in the browser .

Due to these errors, I can not check.

Even in StackOverflow, I did not find anything 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
  });
};
+4
source share

Source: https://habr.com/ru/post/1695741/


All Articles