Skip to content

Commit f963a58

Browse files
committed
setup of testing framework
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
1 parent 2bf5bf4 commit f963a58

File tree

6 files changed

+115
-2
lines changed

6 files changed

+115
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

karma.conf.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Karma configuration
2+
// Generated on Fri Dec 04 2015 17:29:55 GMT-0800 (PST)
3+
4+
module.exports = function(config) {
5+
config.set({
6+
7+
// base path that will be used to resolve all patterns (eg. files, exclude)
8+
basePath: '',
9+
10+
11+
// frameworks to use
12+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
13+
frameworks: ['mocha', 'fixture', 'chai'],
14+
15+
16+
// list of files / patterns to load in the browser
17+
files: [
18+
'bliss.js',
19+
'tests/**/*.js',
20+
'tests/fixtures/**/*.html'
21+
],
22+
23+
24+
// list of files to exclude
25+
exclude: [
26+
],
27+
28+
29+
// preprocess matching files before serving them to the browser
30+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
31+
preprocessors: {
32+
'**/*.html' : ['html2js']
33+
},
34+
35+
36+
// test results reporter to use
37+
// possible values: 'dots', 'progress'
38+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
39+
reporters: ['progress'],
40+
41+
42+
// web server port
43+
port: 9876,
44+
45+
46+
// enable / disable colors in the output (reporters and logs)
47+
colors: true,
48+
49+
50+
// level of logging
51+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
52+
logLevel: config.LOG_INFO,
53+
54+
55+
// enable / disable watching file and executing tests whenever any file changes
56+
autoWatch: true,
57+
58+
59+
// start these browsers
60+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
61+
browsers: ['PhantomJS', 'Chrome'],
62+
63+
64+
// Continuous Integration mode
65+
// if true, Karma captures browsers, runs the tests and exits
66+
singleRun: false,
67+
68+
// Concurrency level
69+
// how many browser should be started simultanous
70+
concurrency: Infinity
71+
})
72+
}

package.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@
2929
"gulp-concat": "^2.6.0",
3030
"gulp-rename": "^1.2.2",
3131
"gulp-uglify": "^1.5.1",
32-
"gulp-util": "^3.0.7"
33-
}
32+
"gulp-util": "^3.0.7",
33+
"karma": "^0.13.15",
34+
"karma-chrome-launcher": "^0.2.2",
35+
"karma-fixture": "^0.2.5",
36+
"karma-html2js-preprocessor": "^0.1.0",
37+
"karma-jasmine": "^0.3.6",
38+
"karma-mocha": "^0.2.1",
39+
"karma-phantomjs-launcher": "^0.2.1",
40+
"karma-requirejs": "^0.2.2",
41+
"phantomjs": "^1.9.19",
42+
"requirejs": "^2.1.22"
43+
},
44+
"dependencies": {}
3445
}

tests/CoreSpec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
describe("Core Bliss", function () {
3+
"use strict";
4+
5+
beforeEach(function () {
6+
fixture.setBase('tests/fixtures')
7+
this.fixture = fixture.load('core.html');
8+
document.body.innerHTML += this.fixture[0]
9+
});
10+
11+
// testing setup
12+
it("has the fixture on the dom", function () {
13+
expect($('#fixture-container')).to.not.be.null;
14+
});
15+
16+
});
17+

tests/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Running the tests
2+
3+
cd to the root of the project
4+
```
5+
karma start
6+
```
7+
8+
thats it, Karma will monitor your tests directory for any files with *Spec.js, and run them on change.

tests/fixtures/core.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
<div id="fixture-container">
3+
<div class="foo"></div>
4+
</div>

0 commit comments

Comments
 (0)