2016-06-22 8 views
0

私は基本的なカルマジャスミンテストを実行しようとしていますが、次のエラーが表示されます。カルマ/ジャスミンテストエラー:「キャッチされていないタイプエラー:予期しない匿名のSystem.registerコール」。

Chrome 51.0.2704 (Windows 7 0.0.0) ERROR 
    Uncaught TypeError: Unexpected anonymous System.register call. 
    at D:/git/ui-components/jspm_packages/system.src.js:2891 


Chrome 51.0.2704 (Windows 7 0.0.0): Executed 0 of 0 SUCCESS (0 secs/0 secs) 

テストは実行されていないようです。
フォルダ構造は以下の通りである:

  • 成分
    - [個々の成分]
    簡単な試験
    -app.jsと -testsフォルダが
(すべての子コンポーネントを呼び出すマスターコンポーネントを含みます)

アプリケーションは正常に動作していますが、テストでは多くの問題が発生しています。
何か助けていただければ幸いです。続き

{ 
    "name": "ui-components", 
    "version": "1.0.0", 
    "description": "POC", 
    "main": "index.js", 
    "scripts": { 
    "install": "jspm install && typings install", 
    "start": "gulp serve" 
    }, 
    "repository": { 
    "type": "git", 
    "url": "" 
    }, 
    "author": "", 
    "license": "ISC", 
    "devDependencies": { 
    "gulp": "^3.9.1", 
    "gulp-typescript": "^2.12.2", 
    "gulp-watch": "^4.3.5", 
    "jasmine": "^2.4.2", 
    "jasmine-core": "^2.4.1", 
    "jspm": "^0.16.30", 
    "karma": "^0.13.22", 
    "karma-chrome-launcher": "^0.2.3", 
    "karma-cli": "file:C:\\Users\\*********\\Downloads\\karma-cli-master", 
    "karma-jasmine": "^0.3.6", 
    "karma-jspm": "^2.0.2", 
    "lite-server": "^2.2.0", 
    "typescript": "^1.8.10", 
    "typings": "^1.0.4" 
    }, 
    "jspm": { 
    "dependencies": { 
     "angular": "github:angular/[email protected]^1.5.0", 
     "angular-route": "github:angular/[email protected]^1.5.0", 
     "bootstrap": "github:twbs/[email protected]^3.3.6", 
     "css": "github:systemjs/[email protected]^0.1.20" 
    }, 
    "devDependencies": {} 
    } 
} 

karma.config.jsが

module.exports = function(config) { 
    config.set({ 
    basePath: '', 
    frameworks: ['jasmine', 'jspm'], 
    files: [ 
     'components/**/*.js', 
     'components/*.js', 
     'components/tests/*.spec.js' 
    ], 
    exclude: [ 
    ], 
    preprocessors: { 
    }, 
    reporters: ['progress'], 
    port: 9876, 
    colors: true, 
    logLevel: config.LOG_INFO, 
    autoWatch: true, 
    browsers: ['Chrome'], 
    singleRun: false, 
    concurrency: Infinity 
    }) 
} 

firstTest.spec.jsが

import angular from 'angular'; 

describe("Hello World Tests",() => { 
    it("First",() => { 
     expect("TestString").toEqual(""); 
    }); 
}); 

index.htmlファイル

をファイルファイル私のpackage.jsonファイルであります
<html ng-app="app"> 
    <head> 
     <script src="jspm_packages/system.js"></script> 
     <script src="config.js"></script> 
     <link rel="stylesheet" href="jspm_packages/github/twbs/[email protected]/css/bootstrap.css" /> 
     <link rel="stylesheet" href="style.css" /> 
     <script> 
       System.import("components/app.js"); 
     </script> 
    </head> 
    <body> 
     <main-component></main-component> 
    </body> 
</html> 

app.tsは

import * as angular from 'angular' 
import 'components/mainComponent/mainComponent' 

angular.module("app", ['mainComponent']); 

答えて

0

ファイル私はkarma.config.jsファイルにJSPM配列オブジェクトで私.TSファイルに渡すために必要なことを考え出しました。私は次のブロックにファイルを渡すことはできませんでした。

files: [ 
     'components/**/*.js', 
     'components/*.js', 
     'components/tests/*.spec.js' 
]` 

代わりにこれが必要です。

jspm: { 
    config: "config.js", 
    packages: "jspm_packages/", 
    loadFiles: ['components/**/*spec.js'], 
    serveFiles: ['components/**/*.js'] 
}, 

うまくいけば、これは他の人の役に立ちます。

関連する問題