-
Notifications
You must be signed in to change notification settings - Fork 939
Expand file tree
/
Copy pathkarma-tests.js
More file actions
55 lines (43 loc) · 1.42 KB
/
karma-tests.js
File metadata and controls
55 lines (43 loc) · 1.42 KB
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
"use strict";
const spawn = require( "child_process" ).spawn;
module.exports = function( grunt ) {
// The task runs tests in various browser sets but does it sequentially in
// separate processes to avoid Karma bugs that cause browsers from previous
// sets to somehow still be waited on during subsequent runs, failing the build.
grunt.registerTask( "karma-tests", "Run unit tests sequentially",
async function( isBrowserStack ) {
const done = this.async();
const tasks = isBrowserStack ? [
"karma:phantom", "karma:desktop", "karma:desktop2",
"karma:oldIe", "karma:oldFirefox", "karma:oldChrome",
"karma:oldSafari", "karma:oldOpera",
"karma:ios"
// BrowserStack no longer shares old iOS simulators
// "karma:oldIos",
// See #314 :-(
// "karma:android", "karma:oldAndroid"
] : [ "karma:phantom" ];
for ( let task of tasks ) {
const command = `grunt ${ task }`;
grunt.log.writeln( `Running task ${ task } in a subprocess...` );
await new Promise( ( resolve, reject ) => {
const ret = spawn( command, {
shell: true,
stdio: "inherit"
} );
ret.on( "close", ( code ) => {
if ( code === 0 ) {
resolve();
} else {
const message = `Error code ${ code } during command: ${ command }`;
console.error( message );
reject( new Error( message ) );
done( false );
}
} );
} );
}
done();
}
);
};