Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed running tests with Karma #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
.idea
node_modules
*.swp
node_modules
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions karma.conf.js.FIXME → karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ 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
exclude: [],

// test results reporter to use
// possible values: 'dots', 'progress', 'junit'
reporters: ['progress'],
reporters: ['dots'],


// web server port
Expand Down Expand Up @@ -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
Expand All @@ -60,6 +60,6 @@ module.exports = function(config) {

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
singleRun: true
});
};
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"devDependencies": {
"karma": "*",
"karma-qunit": "*",
"karma-phantomjs-launcher": "*"
}
}
17 changes: 17 additions & 0 deletions test/qunit-init.js
Original file line number Diff line number Diff line change
@@ -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;
});



2 changes: 1 addition & 1 deletion test/view-model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});