Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Commit

Permalink
feat(test): Run tests with jQuery present
Browse files Browse the repository at this point in the history
Following #8
  • Loading branch information
douglasduteil committed Dec 31, 2013
1 parent 43490d9 commit 7e88f49
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 5 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"angular": "~1.2.1"
},
"devDependencies": {
"angular-mocks": "~1.2.1"
"angular-mocks": "~1.2.1",
"jquery": "~2.0.3"
}
}
12 changes: 8 additions & 4 deletions gruntFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ module.exports = function (grunt) {
grunt.registerTask('serve', ['connect:continuous', 'karma:continuous', 'watch']);
grunt.registerTask('dist', ['ngmin', 'uglify']);

grunt.registerTask('karma:continuous', ['karma:wjqlite_bg', 'karma:wjquery_bg']);
grunt.registerTask('karma:unit', ['karma:wjqlite:unit', 'karma:wjquery:unit']);
grunt.registerTask('karma:unit:run', ['karma:wjqlite:unit:run', 'karma:wjquery:unit:run']);

var testConfig = function (configFile, customOptions) {
var options = { configFile: configFile, singleRun: true };
Expand Down Expand Up @@ -44,9 +47,10 @@ module.exports = function (grunt) {
// TESTER
// =======
karma: {
unit: testConfig('test/karma.conf.js'),
server: {configFile: 'test/karma.conf.js'},
continuous: {configFile: 'test/karma.conf.js', background: true }
wjquery: testConfig('test/karma-jquery.conf.js'),
wjqlite: testConfig('test/karma-jqlite.conf.js'),
wjquery_bg: {configFile: 'test/karma-jquery.conf.js', background: true },
wjqlite_bg: {configFile: 'test/karma-jqlite.conf.js', background: true }
},


Expand All @@ -58,7 +62,7 @@ module.exports = function (grunt) {
tasks: ['jshint:src', 'karma:unit:run', 'dist']
},
test: {
files: ['test/*.js'],
files: ['test/*.spec.js'],
tasks: ['jshint:test', 'karma:unit:run']
},
demo: {
Expand Down
4 changes: 4 additions & 0 deletions test/helpers/jquery_alias.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';
/* global jQuery */

var _jQuery = jQuery;
4 changes: 4 additions & 0 deletions test/helpers/jquery_remove.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';
/* global jQuery */

var _jQuery = jQuery.noConflict(true);
2 changes: 2 additions & 0 deletions test/karma.conf.js → test/karma-jqlite.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ module.exports = function (config) {

// list of files / patterns to load in the browser
files: [
'bower_components/jquery/jquery.js',
'test/helpers/jquery_remove.js',
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'src/*',
Expand Down
75 changes: 75 additions & 0 deletions test/karma-jquery.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Karma configuration
// Generated on Thu Nov 21 2013 15:01:01 GMT+0100 (CET)

module.exports = function (config) {
'use strict';

config.set({

// base path, that will be used to resolve files and exclude
basePath: '..',


// frameworks to use
frameworks: ['jasmine'],


// list of files / patterns to load in the browser
files: [
'bower_components/jquery/jquery.js',
'test/helpers/jquery_alias.js',
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'src/*',
'test/*.spec.js'
],


// list of files to exclude
exclude: [

],


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


// web server port
port: 5432,


// 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: false,


// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera (has to be installed with `npm install karma-opera-launcher`)
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
// - PhantomJS
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
browsers: ['Chrome', 'Firefox', 'PhantomJS'],


// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,


// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
});
};

0 comments on commit 7e88f49

Please sign in to comment.