私はこのチュートリアルを参考にしています:http://www.sitepoint.com/kickstart-your-angularjs-development-with-yeoman-grunt-and-bower/yo generator-angular を使用して作成されるファイルを理解するための手段として。
私は AngularJS の使用経験がありますが、ベストプラクティス ディレクトリを設定する方法を探していました。依存関係を設定して karma を自分で実行する方法がよくわからないため、yeoman ジェネレーターを使用しています。
ただし、何も編集せずにそのまま grunt test を実行すると、次の結果が出力されます。
running "clean:server" (clean) task
Cleaning .tmp...OK
Running "concurrent:test" (concurrent) task
Running "copy:styles" (copy) task
Copied 1 files
Done, without errors
Running "autoprefixer:dist" (autoprefixer) task
Prefixed file ".tmp/styles/main.css" created.
Running "connect:test" (connect) task
Started connect web server on 127.0..0.1:9001.
Running "karma:unit" (karma) task
Warning: No provider for "framework:jasmine"! (resolving: framework:jasmine) Use --force to continue.
Aborted due to warnings.
なぜ Jasmine にプロバイダーがないのか理解できず、この問題を解決する方法もわかりません。package.json ファイルを修正してノードを更新するだけでよいのでしょうか?
編集: 設定ファイルは次のとおりです:
// Karma configuration
// http://karma-runner.github.io/0.10/config/configuration-file.html
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
// testing framework to use (jasmine/mocha/qunit/...)
frameworks:['jasmine'],
// list of files / patterns to load in the browser
files: [
'app/bower_components/angular/angular.js',
'app/bower_components/angular-mocks/angular-mocks.js',
'app/bower_components/angular-resource/angular-resource.js',
'app/scripts/*.js',
'app/scripts/**/*.js',
'test/mock/**/*.js',
'test/spec/**/*.js'
],
// list of files / patterns to exclude
exclude: [],
// web server port
port: 8080,
// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['Chrome'],
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
});
};
ベストアンサー1
私の問題は解決したようですが、同様の問題を抱えている人のために:
karma.conf.js 内に次のコードを追加しました:
plugins: [
'karma-chrome-launcher',
'karma-jasmine'
],
最初は「karma-jasmine」を追加しましたが、「Chrome をロードできません。登録されていません!」というメッセージが表示されました。これは、「karma-chrome-launcher」をプラグインとして追加することで解決しました。
私のせいなのか、それとも generator-angular が古くなっているのかはわかりませんが、今は動作しています。