The main goal for Karma is to bring a productive testing environment to developers. The environment being one where they don`t have to set up loads of configurations, but rather a place where developers can just write the code and get instant feedback from their tests. Because getting quick feedback is what makes you productive and creative.
npm install -g karma-clinpm install karma # Install Karmakarma init # Create configuration filenpm install karma-mocha # Testing frameworknpm install karma-expect # Assertion libnpm install karma-phantomjs-launcher # Browser
karma startINFO [karma]: Karma v0.12.0 server started at http://localhost:9876/INFO [launcher]: Starting browser PhantomJSINFO [PhantomJS 1.9.7 (Linux)]: Connected on socket M64_IXz with id 98199717PhantomJS 1.9.7 (Linux): Executed 1 of 1 SUCCESS (0.011 secs / 0.003 secs)
module.exports = function(config) {config.set({frameworks: ['mocha', 'expect'],files: ['test/**/*.js'],autoWatch: false,singleRun: true,browsers: ['PhantomJS']});}
karma start --single-run=false --auto-watch=true...PhantomJS 1.9.7 (Linux): Executed 1 of 1 SUCCESS (0.038 secs / 0.005 secs)INFO [watcher]: Changed file "/tmp/karma/test/foo_spec.js".PhantomJS 1.9.7 (Linux): Executed 2 of 2 SUCCESS (0.037 secs / 0.006 secs)...
➜ Изменил файл ➜ Тесты ➜ Изменил файл ➜ Тесты ... ➜
module.exports = function(config) {config.set({files: ['src/**/*.js', 'test/*.coffee', 'lib/*.dart'],preprocessors: {'**/*.js': ['borschik'],'**/*.coffee': ['coffee'],'**/*.dart': ['dart']}});}
Просто зайдите на host где запущен karma-server
Karma v0.12.0 server started at http://localhost:9876/...PhantomJS 1.9.7 (Linux): Executed 2 of 2 SUCCESS (0.03 secs / 0.009 secs)Chromium 31.0.1650 (Ubuntu): Executed 2 of 2 SUCCESS (0.27 secs / 0.009 secs)TOTAL: 4 SUCCESS
http://localhost:9876/debug.html
Максим Рыжиков, Yandex