Skip to content

Commit

Permalink
setup of testing framework
Browse files Browse the repository at this point in the history
setting up Karma, Mocha, and fixtures
this gives us a test runner and the
ability to load html fixtures. Right now
Karma is just setup to use Chrome and Phantom
  • Loading branch information
dperrymorrow committed Dec 5, 2015
1 parent 2bf5bf4 commit f963a58
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
node_modules
72 changes: 72 additions & 0 deletions karma.conf.js
@@ -0,0 +1,72 @@
// Karma configuration
// Generated on Fri Dec 04 2015 17:29:55 GMT-0800 (PST)

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: ['mocha', 'fixture', 'chai'],


// list of files / patterns to load in the browser
files: [
'bliss.js',
'tests/**/*.js',
'tests/fixtures/**/*.html'
],


// 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: {
'**/*.html' : ['html2js']
},


// 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: ['PhantomJS', 'Chrome'],


// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// Concurrency level
// how many browser should be started simultanous
concurrency: Infinity
})
}
15 changes: 13 additions & 2 deletions package.json
Expand Up @@ -29,6 +29,17 @@
"gulp-concat": "^2.6.0",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.5.1",
"gulp-util": "^3.0.7"
}
"gulp-util": "^3.0.7",
"karma": "^0.13.15",
"karma-chrome-launcher": "^0.2.2",
"karma-fixture": "^0.2.5",
"karma-html2js-preprocessor": "^0.1.0",
"karma-jasmine": "^0.3.6",

This comment has been minimized.

Copy link
@renoirb

renoirb Jan 6, 2016

We have karma-jasmine already. +1

This comment has been minimized.

Copy link
@LeaVerou

LeaVerou Jan 6, 2016

Owner

Huh? This commit is a month old :P

"karma-mocha": "^0.2.1",
"karma-phantomjs-launcher": "^0.2.1",
"karma-requirejs": "^0.2.2",
"phantomjs": "^1.9.19",
"requirejs": "^2.1.22"
},
"dependencies": {}
}
17 changes: 17 additions & 0 deletions tests/CoreSpec.js
@@ -0,0 +1,17 @@

describe("Core Bliss", function () {
"use strict";

beforeEach(function () {
fixture.setBase('tests/fixtures')
this.fixture = fixture.load('core.html');
document.body.innerHTML += this.fixture[0]
});

// testing setup
it("has the fixture on the dom", function () {
expect($('#fixture-container')).to.not.be.null;
});

});

8 changes: 8 additions & 0 deletions tests/README.md
@@ -0,0 +1,8 @@
# Running the tests

cd to the root of the project
```
karma start
```

thats it, Karma will monitor your tests directory for any files with *Spec.js, and run them on change.
4 changes: 4 additions & 0 deletions tests/fixtures/core.html
@@ -0,0 +1,4 @@

<div id="fixture-container">
<div class="foo"></div>
</div>

0 comments on commit f963a58

Please sign in to comment.