1
-
2
- /*global jasmine, __karma__, window*/
3
1
import 'core-js/es6' ;
4
2
import 'core-js/es7/reflect' ;
5
3
@@ -16,22 +14,27 @@ import 'zone.js/dist/sync-test';
16
14
// RxJS
17
15
import 'rxjs/Rx' ;
18
16
19
- Promise . all ( [
20
- System . import ( '@angular/core/testing' ) ,
21
- System . import ( '@angular/platform-browser-dynamic/testing' )
22
- ] ) . then ( function ( providers ) {
23
- let testing = providers [ 0 ] ;
24
- let testingBrowser = providers [ 1 ] ;
17
+ // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
18
+ declare var __karma__ : any ;
19
+
20
+ // Prevent Karma from running prematurely.
21
+ __karma__ . loaded = function ( ) { } ;
22
+
25
23
24
+ Promise . all ( [
25
+ System . import ( '@angular/core/testing' ) ,
26
+ System . import ( '@angular/platform-browser-dynamic/testing' )
27
+ ] )
28
+ // First, initialize the Angular testing environment.
29
+ . then ( ( [ testing , testingBrowser ] ) => {
26
30
testing . setBaseTestProviders (
27
31
testingBrowser . TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS ,
28
32
testingBrowser . TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
29
33
) ;
30
- } ) ;
31
-
32
- let testContext : any = require . context ( './' , true , / \. s p e c \. t s / ) ;
33
- function requireAll ( requireContext : any ) {
34
- return requireContext . keys ( ) . map ( requireContext ) ;
35
- }
36
-
37
- requireAll ( testContext ) ;
34
+ } )
35
+ // Then we find all the tests.
36
+ . then ( ( ) => require . context ( './' , true , / \. s p e c \. t s / ) )
37
+ // And load the modules.
38
+ . then ( context => context . keys ( ) . map ( context ) )
39
+ // Finally, start Karma to run the tests.
40
+ . then ( __karma__ . start , __karma__ . error ) ;
0 commit comments