2017-08-29 57 views
0

我使用@ types/fhir,而JIT和AOT看到fhir命名空間很好,運行ng test沒有。我怎樣才能調試呢?角度測試看不到類型

我的tsconfig.json已經有"typeRoots": [ "node_modules/@types" ]在裏面。

package.json

{ 
    "scripts": { 
    "ng": "ng", 
    "start": "ng serve", 
    "build": "ng build", 
    "test": "ng test", 
    "lint": "ng lint", 
    "e2e": "ng e2e" 
    }, 
    "private": true, 
    "dependencies": { 
    "@angular/animations": "^4.0.0", 
    "@angular/common": "^4.0.0", 
    "@angular/compiler": "^4.0.0", 
    "@angular/core": "^4.0.0", 
    "@angular/forms": "^4.0.0", 
    "@angular/http": "^4.0.0", 
    "@angular/platform-browser": "^4.0.0", 
    "@angular/platform-browser-dynamic": "^4.0.0", 
    "@angular/router": "^4.0.0", 
    "@types/fhir": "0.0.30", 
    "bootstrap": "^4.0.0-beta", 
    "core-js": "^2.4.1", 
    "font-awesome": "^4.7.0", 
    "ng2-slim-loading-bar": "^4.0.0", 
    "ngx-bootstrap": "^2.0.0-beta.4", 
    "ngx-infinite-scroll": "^0.5.1", 
    "rxjs": "^5.4.1", 
    "zone.js": "^0.8.14" 
    }, 
    "devDependencies": { 
    "@angular/cli": "1.2.6", 
    "@angular/compiler-cli": "^4.0.0", 
    "@angular/language-service": "^4.0.0", 
    "@types/fhir": "0.0.30", 
    "@types/jasmine": "~2.5.53", 
    "@types/jasminewd2": "~2.0.2", 
    "@types/node": "~8.0.19", 
    "codelyzer": "~3.1.2", 
    "jasmine-core": "~2.7.0", 
    "jasmine-spec-reporter": "~4.1.0", 
    "karma": "~1.7.0", 
    "karma-chrome-launcher": "~2.2.0", 
    "karma-cli": "~1.0.1", 
    "karma-coverage-istanbul-reporter": "^1.2.1", 
    "karma-jasmine": "~1.1.0", 
    "karma-jasmine-html-reporter": "^0.2.2", 
    "protractor": "~5.1.2", 
    "ts-node": "~3.3.0", 
    "tslint": "~5.5.0", 
    "typescript": "~2.4.2" 
    } 
} 

karma.conf.js

// Karma configuration file, see link for more information 
// https://karma-runner.github.io/0.13/config/configuration-file.html 

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') 
    ], 
    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 
    }); 
}; 
+0

你的package.json在AOT和ng測試中的外觀如何? – Swoox

+0

增加package.json! – Vadi

+1

看起來好像看看你的** karma.conf **有ng測試的配置。 – Swoox

回答

1

看看你.angular-cli.json,可以有 「testTsconfig」 屬性導致另一個tsconfig(tsconfig.spec.json )。在該文件中,您可以在類型數組中指定fhir。

+0

謝謝!編輯工作:) – Vadi