forked from litixsoft/karma-detect-browsers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
106 lines (98 loc) · 2.94 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
'use strict';
var karmaConfig = {
demo: {
configFile: 'demo/karma.conf.js'
},
disabled: {
configFile: 'demo/karma.conf.js',
detectBrowsers: {
enabled: false
}
},
phantomjs_disabled: {
configFile: 'demo/karma.conf.js',
detectBrowsers: {
usePhantomJS: false
}
},
noLogging: {
configFile: 'demo/karma.conf.js',
logLevel: 'ERROR'
}
};
if(process.env.TRAVIS) {
for(var keys = Object.keys(karmaConfig), i = 0; i < keys.length; i++) {
var config = karmaConfig[keys[i]];
config.customLaunchers = {
ChromeHeadless_travis_ci: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
},
ChromiumHeadless_travis_ci: {
base: 'ChromiumHeadless',
flags: ['--no-sandbox']
}
};
config.detectBrowsers = config.detectBrowsers || {};
config.detectBrowsers.preferHeadless = true;
config.detectBrowsers.postDetection = function(browsers) {
var chromeHeadlessIndex = browsers.indexOf('ChromeHeadless');
if(chromeHeadlessIndex !== -1) {
browsers[chromeHeadlessIndex] = 'ChromeHeadless_travis_ci';
}
var chromiumHeadlessIndex = browsers.indexOf('ChromiumHeadless');
if(chromiumHeadlessIndex !== -1) {
browsers[chromiumHeadlessIndex] = 'ChromiumHeadless_travis_ci';
}
return browsers;
};
}
}
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
options: {
bitwise: true,
curly: true,
eqeqeq: true,
forin: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
noempty: true,
nonew: true,
regexp: true,
undef: true,
unused: true,
indent: 4,
quotmark: 'single',
loopfunc: true,
browser: true,
node: true,
globals: {
}
},
test: ['Gruntfile.js', 'index.js']
},
copy: {
demo: {
expand: true,
src: ['index.js', 'browsers/**'],
dest: 'node_modules/karma-detect-browsers'
}
},
karma: karmaConfig
});
// Load tasks.
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-karma');
// Register tasks.
grunt.registerTask('test', ['jshint:test']);
grunt.registerTask('demo', ['copy:demo', 'karma']);
// Default task.
grunt.registerTask('default', ['test']);
};