2017-01-17 125 views
0

Phantom的Runing karma測試很好,但在Chrome中不行。我在karma.config中更改的所有內容爲browsers: ['PhantomJS'],browsers: ['Chrome'],。 如果我改變它,我有0測試執行和Test failedKarma測試適用於PhantomJs,但不適用於Chrome

這裏是我的Chrome響應: enter image description here

這裏是我的karma.config.js

// Karma configuration 
// Generated on Mon Jan 16 2017 13:32:24 GMT+0100 (Środkowoeuropejski czas stand.) 
var webpackConfig = require('./webpack.config.js'); 
var webpack = require('webpack'); 
var path = require('path'); 

module.exports = function (config) { 
    config.set({ 
     basePath: '', 
     frameworks: ['mocha', 'chai', 'sinon', 'fixture'], 
     files: [ 
      'spec/**/*.spec.ts', 
      'spec/fixtures/**/*.html', 
     ], 
     exclude: [], 
     webpack: { 
      module: webpackConfig.module, 
      resolve: webpackConfig.resolve, 
      plugins: [ 
       new webpack.ProvidePlugin({ 
        $: "jquery", 
        jQuery: "jquery", 
        "window.jQuery": "jquery", 
        Tether: 'tether', 
        "window.Tether": 'tether' 
       }) 
      ], 
     }, 
     preprocessors: { 
      "spec/**/*.ts": ['webpack'], 
      'spec/**/*.html': ['html2js'], 
      'spec/**/*.json': ['json_fixtures'] 
     }, 
     reporters: ['progress'], 
     port: 9876, 
     colors: true, 
     logLevel: config.LOG_INFO, 
     autoWatch: false, 
     // browsers: ['Chrome'], 
     browsers: ['PhantomJS'], 
     singleRun: true, 
     concurrency: Infinity 
    }) 
}; 

和包裝:

"devDependencies": { 
    "@types/chai": "^3.4.34", 
    "@types/jquery": "^2.0.34", 
    "@types/karma-fixture": "^0.2.2", 
    "@types/mocha": "^2.2.37", 
    "@types/raty": "^2.7.26", 
    "@types/sinon": "^1.16.34", 
    "chai": "^3.5.0", 
    "css-loader": "^0.26.1", 
    "extract-text-webpack-plugin": "^2.0.0-beta.4", 
    "file-loader": "^0.9.0", 
    "karma": "^1.4.0", 
    "karma-chai": "^0.1.0", 
    "karma-chrome-launcher": "^2.0.0", 
    "karma-fixture": "^0.2.6", 
    "karma-html2js-preprocessor": "^1.1.0", 
    "karma-json-fixtures-preprocessor": "0.0.6", 
    "karma-mocha": "^1.3.0", 
    "karma-mocha-reporter": "^2.2.1", 
    "karma-phantomjs-launcher": "^1.0.2", 
    "karma-sinon": "^1.0.5", 
    "karma-typescript": "^2.1.6", 
    "karma-typescript-preprocessor2": "^1.2.1", 
    "karma-webpack": "^2.0.1", 
    "less": "^2.7.2", 
    "mocha": "^3.2.0", 
    "node-sass": "^4.0.0", 
    "phantomjs-prebuilt": "^2.1.14", 
    "sass-loader": "^4.0.2", 
    "sinon": "^1.17.7", 
    "style-loader": "^0.13.1", 
    "ts-loader": "^1.2.2", 
    "typescript": "^2.0.10", 
    "url-loader": "^0.5.7", 
    "webpack": "^2.2.0-rc.6" 
    } 

回答

4
enter image description here

與幻影響應

添加MIME配置karma.conf固定一個類似的問題對我來說:

要在Chrome調試定義因果報應配置:

autowatch:true 

,並定義:

singleRun: false 

開始你的業障測試並在Chrome中打開karma服務器的頁面。

在控制檯中顯示以下錯誤:

Refused to execute script from 
'http://localhost:9876/base/src/app/search-persons/search- 
persons.component.spec.ts?fe78e0d6a85c32fb65115ec3fd4e171b9f39ded7' 
because its MIME type ('video/mp2t') is not executable. 

的mime配置是固定的這對我來說:

mime: { 
    'text/x-typescript': ['ts'] 
}, 
相關問題