-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
114 lines (97 loc) · 3.17 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
107
108
109
110
111
112
113
114
'use strict';
var _ = require('lodash');
// by default, use Sauce Labs
// if you don't want Sauce, use SAUCE=false
//if (process.env.SAUCE === undefined) {
// process.env.SAUCE = false;
//}
var desireds = require('./tests/functional/helpers/caps');
var gruntConfig = {
env: {
// dynamically filled
},
simplemocha: {
ios: {
options: {
timeout: 120000,
reporter: 'spec'
},
src: ['tests/functional/ios/*-specs.js']
},
android: {
options: {
timeout: 120000,
reporter: 'spec'
},
src: ['tests/functional/android/*-specs.js']
}
},
concurrent: {
// dynamically filled
'test-ios': [],
'test-android': [],
'test-all': []
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
gruntfile: {
src: 'Gruntfile.js'
},
test: {
src: ['tests/**/*.js']
}
},
watch: {
js: {
files: ['Gruntfile.js', 'tests/**/*.js'],
tasks: ['jshint'],
options: {
spawn: false
}
}
}
};
// configure
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig(gruntConfig);
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-simple-mocha');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
var tests = [];
_.each(['ios', 'android'], function (system) {
var systemTests = [];
_(desireds[system]).each(function (desired, key) {
// put together environments for each test
gruntConfig.env[key] = {
DESIRED: JSON.stringify(desired)
};
var name = 'test:' + system + ':' + key;
// establish the list of tasks for the system's concurrent task
gruntConfig.concurrent['test-' + system].push('test:' + system + ':' + key);
// establish the list of tasks for all concurrent tasks
gruntConfig.concurrent['test-all'].push(name);
// make a task for this particular cap (e.g., grunt test:ios:7.1)
grunt.registerTask(name, ['env:' + key, 'simplemocha:' + system]);
// add to the list of tests for this particular system
systemTests.push(name);
// add to the list of tests that will be performed as 'all'
tests.push(name);
});
// make a task for a particular system (e.g., grunt test:ios)
grunt.registerTask('test:' + system, systemTests);
});
// make a task that does all the systems, serially
grunt.registerTask('test:all', tests);
// make parallel tasks
grunt.registerTask('test:ios:parallel', ['concurrent:test-ios']);
grunt.registerTask('test:android:parallel', ['concurrent:test-android']);
grunt.registerTask('test:all:parallel', ['concurrent:test-all']);
// default task
grunt.registerTask('default', ['test:all']);
};