diff --git a/.gitignore b/.gitignore index 6d84185..bb8ce8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store .idea -node_modules \ No newline at end of file +*.swp +node_modules diff --git a/README.md b/README.md index 4a77c90..262f616 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,10 @@ You can run the automated tests in one of two ways: 1. Open the following files in your browser: `backbone-view-model/test/basic.html` and `backbone-view-model/test/require-js.html`. -2. Karma: Right now this is broken. TODO - can someone help fix this? +2. Karma +2a. npm -g install karma-cli +2b. npm install +2c. karma start ## Contributing diff --git a/karma.conf.js.FIXME b/karma.conf.js similarity index 90% rename from karma.conf.js.FIXME rename to karma.conf.js index eb73182..3a87695 100644 --- a/karma.conf.js.FIXME +++ b/karma.conf.js @@ -10,9 +10,9 @@ module.exports = function(config) { files: [ 'test/lib/underscore-1.3.1.js', 'test/lib/backbone-0.9.2.js', - 'test/lib/require.js', 'src/*.js', - 'test/*.js' + 'test/qunit-init.js', + 'test/view-model.test.js' ], // list of files to exclude @@ -20,7 +20,7 @@ module.exports = function(config) { // test results reporter to use // possible values: 'dots', 'progress', 'junit' - reporters: ['progress'], + reporters: ['dots'], // web server port @@ -51,7 +51,7 @@ module.exports = function(config) { // - Safari (only Mac) // - PhantomJS // - IE (only Windows) - browsers: ['Chrome'], + browsers: ['PhantomJS'], // If browser does not capture in given timeout [ms], kill it @@ -60,6 +60,6 @@ module.exports = function(config) { // Continuous Integration mode // if true, it capture browsers, run tests and exit - singleRun: false + singleRun: true }); }; diff --git a/package.json b/package.json new file mode 100644 index 0000000..0dbb377 --- /dev/null +++ b/package.json @@ -0,0 +1,7 @@ +{ + "devDependencies": { + "karma": "*", + "karma-qunit": "*", + "karma-phantomjs-launcher": "*" + } +} diff --git a/test/qunit-init.js b/test/qunit-init.js new file mode 100644 index 0000000..1a61340 --- /dev/null +++ b/test/qunit-init.js @@ -0,0 +1,17 @@ +// QUnit has problems with counting the total number of tests, issue is explained +// here including a fix: https://github.com/karma-runner/karma/issues/966 + +var testCount = 0; +var qunitTest = QUnit.test; + +QUnit.test = window.test = function () { + testCount += 1; + qunitTest.apply(this, arguments); +}; + +QUnit.begin(function (args) { + args.totalTests = testCount; +}); + + + diff --git a/test/view-model.test.js b/test/view-model.test.js index db16409..6cb0969 100644 --- a/test/view-model.test.js +++ b/test/view-model.test.js @@ -131,4 +131,4 @@ test("computed_attributes: A ViewModel's attributes will be updated on change ev rhs.set('a', 22); deepEqual(viewModel.get("message"), "Sum: 19", "irrelevant atribute update become a noop"); -}); \ No newline at end of file +});