Skip to content

Commit 3ff2997

Browse files
committed
add Jasmine unit testing framework to grunt
1 parent 92bfd93 commit 3ff2997

4 files changed

Lines changed: 36 additions & 7 deletions

File tree

Gruntfile.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@ module.exports = function(grunt) {
88
options: {
99
jshintrc: true
1010
}
11+
},
12+
jasmine: {
13+
src: ['background.js', 'main.js', 'views/*.js'],
14+
options: {
15+
specs: 'tests/spec/*.spec.js',
16+
helpers: 'tests/spec/*.helper.js'
17+
}
1118
}
1219
});
1320

14-
grunt.loadNpmTasks('grunt-contrib-uglify');
1521
grunt.loadNpmTasks('grunt-contrib-jshint');
16-
grunt.loadNpmTasks('grunt-contrib-nodeunit');
22+
grunt.loadNpmTasks('grunt-contrib-jasmine');
1723

18-
grunt.registerTask('default', ['uglify']);
19-
grunt.registerTask('test', ['jshint']);
24+
grunt.registerTask('default', ['jshint', 'jasmine']);
25+
grunt.registerTask('test', ['jshint', 'jasmine']);
2026

2127
};

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@
2525
},
2626
"devDependencies": {
2727
"grunt": "~0.4.5",
28-
"grunt-contrib-jshint": "~0.10.0",
29-
"grunt-contrib-nodeunit": "~0.3.3",
30-
"grunt-contrib-uglify": "~0.4.0"
28+
"grunt-contrib-jasmine": "^0.6.5",
29+
"grunt-contrib-jshint": "~0.10.0"
3130
},
3231
"dependencies": {
3332
"bower": "^1.3.6",

tests/spec/basic.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe("A suite", function() {
2+
it("contains spec with an expectation", function() {
3+
expect(true).toBe(true);
4+
});
5+
});

tests/spec/chrome.helper.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// mocking the Chrome API
2+
3+
chrome = {
4+
runtime: {
5+
onConnect: {
6+
addListener: function(){}
7+
}
8+
},
9+
devtools: {
10+
panels: {
11+
create: function(){}
12+
}
13+
},
14+
tabs: {
15+
onUpdated: {
16+
addListener: function(){}
17+
}
18+
}
19+
};

0 commit comments

Comments
 (0)