1
1
/*global jasmine, __karma__, window*/
2
2
Error . stackTraceLimit = Infinity ;
3
-
4
3
jasmine . DEFAULT_TIMEOUT_INTERVAL = 1000 ;
5
4
6
5
__karma__ . loaded = function ( ) {
7
6
} ;
8
7
9
- System . config ( {
10
- packages : {
11
- 'base/dist/app' : {
12
- defaultExtension : false ,
13
- format : 'register' ,
14
- map : Object . keys ( window . __karma__ . files )
15
- . filter ( onlyAppFiles )
16
- . reduce ( function ( pathsMapping , appPath ) {
17
- var moduleName = appPath . replace ( / ^ \/ b a s e \/ d i s t \/ a p p \/ / , './' ) . replace ( / \. j s $ / , '' ) ;
18
- pathsMapping [ moduleName ] = appPath + '?' + window . __karma__ . files [ appPath ] ;
19
- return pathsMapping ;
20
- } , { } )
21
- }
22
- }
23
- } ) ;
8
+ var distPath = '/base/dist/' ;
9
+ var appPath = distPath + 'app/' ;
24
10
25
- System . import ( 'angular2/testing' ) . then ( function ( testing ) {
26
- return System . import ( 'angular2/platform/testing/browser' ) . then ( function ( providers ) {
27
- testing . setBaseTestProviders ( providers . TEST_BROWSER_PLATFORM_PROVIDERS ,
28
- providers . TEST_BROWSER_APPLICATION_PROVIDERS ) ;
29
- } ) ;
30
- } ) . then ( function ( ) {
31
- return Promise . all (
32
- Object . keys ( window . __karma__ . files )
33
- . filter ( onlySpecFiles )
34
- . map ( function ( moduleName ) {
35
- return System . import ( moduleName ) ;
36
- } ) ) ;
37
- } ) . then ( function ( ) {
38
- __karma__ . start ( ) ;
39
- } , function ( error ) {
40
- __karma__ . error ( error . stack || error ) ;
41
- } ) ;
42
-
43
- function onlyAppFiles ( filePath ) {
44
- return / ^ \/ b a s e \/ d i s t \/ a p p \/ (? ! .* \. s p e c \. j s $ ) ( [ a - z 0 - 9 -_ \. \/ ] + ) \. j s $ / . test ( filePath ) ;
11
+ function isJsFile ( path ) {
12
+ return path . slice ( - 3 ) == '.js' ;
45
13
}
46
14
47
- function onlySpecFiles ( path ) {
48
- return / \. s p e c \ .j s $ / . test ( path ) ;
15
+ function isSpecFile ( path ) {
16
+ return path . slice ( - 8 ) == '. spec.js' ;
49
17
}
18
+
19
+ function isAppFile ( path ) {
20
+ return isJsFile ( path ) && ( path . substr ( 0 , appPath . length ) == appPath ) ;
21
+ }
22
+
23
+ var allSpecFiles = Object . keys ( window . __karma__ . files )
24
+ . filter ( isSpecFile )
25
+ . filter ( isAppFile ) ;
26
+
27
+ // Load our SystemJS configuration.
28
+ System . import ( 'base/dist/system-config.js' ) . then ( function ( systemJsConfig ) {
29
+ // We need to add the distPrefix to our system config packages.
30
+ var config = systemJsConfig . config ;
31
+ Object . keys ( config . packages ) . forEach ( function ( pkgName ) {
32
+ if ( pkgName [ 0 ] != '/' && pkgName [ 0 ] != '.' ) {
33
+ var pkg = config . packages [ pkgName ] ;
34
+ delete config . packages [ pkgName ] ;
35
+ config . packages [ distPath + pkgName ] = pkg ;
36
+ }
37
+ } ) ;
38
+
39
+ System . config ( config ) ;
40
+ } ) . then ( function ( ) {
41
+ // Load and configure the TestComponentBuilder.
42
+ return Promise . all ( [
43
+ System . import ( 'angular2/testing' ) ,
44
+ System . import ( 'angular2/platform/testing/browser' )
45
+ ] ) . then ( function ( providers ) {
46
+ var testing = providers [ 0 ] ;
47
+ var testingBrowser = providers [ 1 ] ;
48
+
49
+ testing . setBaseTestProviders ( testingBrowser . TEST_BROWSER_PLATFORM_PROVIDERS ,
50
+ testingBrowser . TEST_BROWSER_APPLICATION_PROVIDERS ) ;
51
+ } ) ;
52
+ } ) . then ( function ( ) {
53
+ // Finally, load all spec files.
54
+ // This will run the tests directly.
55
+ return Promise . all (
56
+ allSpecFiles . map ( function ( moduleName ) {
57
+ return System . import ( moduleName ) ;
58
+ } ) ) ;
59
+ } ) . then ( __karma__ . start , __karma__ . error ) ;
0 commit comments