Tôi đã sử dụng Karma khoảng 1 năm trước và mọi thứ hoạt động tốt. Khi tôi thay đổi các thử nghiệm và lưu tệp .test.js, kiểm tra tự động chạy - không phải khởi động lại hoặc thay đổi bất cứ điều gì. Hôm nay tôi muốn chạy lại các thử nghiệm này. Có một máy tính mới, tôi phải cài đặt nút và NPM và không có điều gì, và sau đó tôi cũng được cài đặt:Karma auto-watch không hoạt động
npm install -g karma karma-cli karma-jasmine karma-chrome-launcher
tôi cấu hình Karma như sau (karma init
):
// Karma configuration
// Generated on Thu Apr 14 2016 14:50:35 GMT+0200 (Central Europe Summer Time)
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: [
'js/*.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: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
Khi tôi bắt đầu nghiệp (karma start karma.conf.js
) một tab chrome mới mở ra, với cổng, được chỉ định trong tệp cấu hình. Bài kiểm tra chạy, mọi thứ hoạt động như mong đợi. Tuy nhiên, khi tôi thay đổi một cái gì đó trong tập tin .test.js
, Karma đã không tự động chạy. Trên thực tế, không có thay đổi nào được thực hiện. Tôi đã phải khởi động lại Karma trong CMD và chạy lại để xem kết quả mới.
Tuy nhiên, nếu tôi mở một CMD mới và thực thi karma run
thì thử nghiệm sẽ được cập nhật. Vì vậy, phần mà đồng hồ thay đổi không hoạt động, rõ ràng.
Vì vậy, tôi không biết mình đang thiếu gì ở đây, nhưng chức năng tự động xem của Karma không hoạt động nữa. Bất kỳ đề xuất nào tôi nên bắt đầu?
Were bạn đã bao giờ có thể giải quyết này? Nếu vậy xin vui lòng gửi câu trả lời của bạn. – Chic