我繼egghead.io「簡介噶」教程這裏找到https://egghead.io/lessons/unit-testing-introduction-to-karma任何結果,並遵循以下(在Windows上):karma.js沒有返回以下基本「報應初始化」設置
> npm install --g karma-cli
> npm install karma karma-jasmine karma-chrome-launcher --save-dev
karma init
初始因緣配置其次默認配置,然後當前文件夾中創建一個文件test.spec.js用下面的代碼:
describe('Test', function() {
it('It should be true', function() { expect(true).toBe(true); });
});
最後,我加入這樣的文件到像karma.conf.js文件所以:
files: [
'test.spec.js'
],
然而,一旦運行
karma start karma.conf.js
我得到不過是:
25 11 2015 16:35:35.551:INFO [karma]: Karma v0.13.15 server started at http://localhost:9876/
爲什麼沒有任何測試執行?此外,打開該localhost url(這與在karma.conf.js中將瀏覽器設置爲['chrome']相同)只是顯示業力正在運行,而且chrome空閒,但沒有返回測試結果。
編輯:上架karma.conf.js
// Karma configuration
// Generated on Wed Nov 25 2015 16:19:43 GMT-0600 (Central Standard Time (Mexico))
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files/patterns to load in the browser
files: [
'*spec.js'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable/disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable/disable watching file and executing tests whenever any file changes
autoWatch: false,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser should be started simultanous
concurrency: Infinity
})
}
EDIT2:增加的package.json
{
"name": "karma-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "karma start karma.conf.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"jasmine-core": "^2.3.4",
"karma": "^0.13.15",
"karma-chrome-launcher": "^0.2.1",
"karma-jasmine": "^0.3.6"
}
}
EDIT3:實測值的溶液。檢查我自己的回覆
你可以分享'karma.conf.js'嗎? – Merott
完成,補充說,和package.json –
我相信這是一個http://stackoverflow.com/questions/25199900/karma-test-runner-not-running-any-tests –