33// Note: Wallaby is not open source and costs money
44
55module . exports = function ( ) {
6-
76 return {
87 files : [
98 // System.js for module loading
109 { pattern : 'node_modules/systemjs/dist/system.js' , instrument : false } ,
1110 { pattern : 'systemjs.config.js' , instrument : false } ,
11+ { pattern : 'systemjs.config.extras.js' , instrument : false } ,
1212
1313 // Polyfills
1414 { pattern : 'node_modules/core-js/client/shim.min.js' , instrument : false } ,
15-
16- // Reflect, Zone.js, and test shims
17- // Rx.js, Angular 2 itself, and the testing library not here because loaded by systemjs
1815 { pattern : 'node_modules/reflect-metadata/Reflect.js' , instrument : false } ,
16+
17+ // zone.js
1918 { pattern : 'node_modules/zone.js/dist/zone.js' , instrument : false } ,
19+ { pattern : 'node_modules/zone.js/dist/long-stack-trace-zone.js' , instrument : false } ,
20+ { pattern : 'node_modules/zone.js/dist/proxy.js' , instrument : false } ,
21+ { pattern : 'node_modules/zone.js/dist/sync-test.js' , instrument : false } ,
2022 { pattern : 'node_modules/zone.js/dist/jasmine-patch.js' , instrument : false } ,
2123 { pattern : 'node_modules/zone.js/dist/async-test.js' , instrument : false } ,
2224 { pattern : 'node_modules/zone.js/dist/fake-async-test.js' , instrument : false } ,
2325
26+ // application (but not specs) loaded via module imports
2427 { pattern : 'app/**/*+(ts|html|css)' , load : false } ,
25- { pattern : 'app/**/*.spec.ts' , ignore : true }
28+ { pattern : 'app/**/*.spec.ts' , ignore : true } ,
29+
30+ { pattern : 'testing/**/*+(ts|html|css)' , load : false } ,
2631 ] ,
2732
2833 tests : [
@@ -37,41 +42,78 @@ module.exports = function () {
3742
3843 debug : true ,
3944
40- bootstrap : function ( wallaby ) {
41- wallaby . delayStart ( ) ;
42-
43- System . config ( {
44- packageWithIndex : true // sadly, we can't use umd packages (yet?)
45- } ) ;
46-
47- System . import ( 'systemjs.config.js' )
48- . then ( function ( ) {
49- return Promise . all ( [
50- System . import ( '@angular/core/testing' ) ,
51- System . import ( '@angular/platform-browser-dynamic/testing' )
52- ] )
53- } )
54- . then ( function ( providers ) {
55- var testing = providers [ 0 ] ;
56- var testingBrowser = providers [ 1 ] ;
57-
58- testing . setBaseTestProviders (
59- testingBrowser . TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS ,
60- testingBrowser . TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS ) ;
61-
62- // Load all spec files
63- return Promise . all ( wallaby . tests . map ( function ( specFile ) {
64- return System . import ( specFile ) ;
65- } ) ) ;
66- } )
67- . then ( function ( ) {
68- wallaby . start ( ) ;
69- } )
70- . catch ( function ( e ) {
71- setTimeout ( function ( ) {
72- throw e ;
73- } , 0 ) ;
74- } ) ;
75- }
45+ bootstrap : bootstrap
7646 } ;
7747} ;
48+
49+ // Like karma-test-shim.js
50+ function bootstrap ( wallaby ) {
51+ wallaby . delayStart ( ) ;
52+
53+ System . config ( {
54+ // Extend usual application package list with test folder
55+ packages : { 'testing' : { main : 'index.js' , defaultExtension : 'js' } } ,
56+
57+ // Assume npm: is set in `paths` in systemjs.config
58+ // Map the angular testing umd bundles
59+ map : {
60+ '@angular/core/testing' : 'npm:@angular/core/bundles/core-testing.umd.js' ,
61+ '@angular/common/testing' : 'npm:@angular/common/bundles/common-testing.umd.js' ,
62+ '@angular/compiler/testing' : 'npm:@angular/compiler/bundles/compiler-testing.umd.js' ,
63+ '@angular/platform-browser/testing' : 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js' ,
64+ '@angular/platform-browser-dynamic/testing' : 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js' ,
65+ '@angular/http/testing' : 'npm:@angular/http/bundles/http-testing.umd.js' ,
66+ '@angular/router/testing' : 'npm:@angular/router/bundles/router-testing.umd.js' ,
67+ '@angular/forms/testing' : 'npm:@angular/forms/bundles/forms-testing.umd.js' ,
68+ } ,
69+ } ) ;
70+
71+ System . import ( 'systemjs.config.js' )
72+ . then ( importSystemJsExtras )
73+ . then ( initTestBed )
74+ . then ( initTesting ) ;
75+
76+ /** Optional SystemJS configuration extras. Keep going w/o it */
77+ function importSystemJsExtras ( ) {
78+ return System . import ( 'systemjs.config.extras.js' )
79+ . catch ( function ( reason ) {
80+ console . log (
81+ 'WARNING: System.import could not load "systemjs.config.extras.js"; continuing without it.'
82+ ) ;
83+ console . log ( reason ) ;
84+ } ) ;
85+ }
86+
87+ function initTestBed ( ) {
88+ return Promise . all ( [
89+ System . import ( '@angular/core/testing' ) ,
90+ System . import ( '@angular/platform-browser-dynamic/testing' )
91+ ] )
92+
93+ . then ( function ( providers ) {
94+ var coreTesting = providers [ 0 ] ;
95+ var browserTesting = providers [ 1 ] ;
96+
97+ coreTesting . TestBed . initTestEnvironment (
98+ browserTesting . BrowserDynamicTestingModule ,
99+ browserTesting . platformBrowserDynamicTesting ( ) ) ;
100+ } )
101+ }
102+
103+ // Load all spec files and start wallaby
104+ function initTesting ( ) {
105+ return Promise . all (
106+ wallaby . tests . map ( function ( specFile ) {
107+ return System . import ( specFile ) ;
108+ } )
109+ )
110+ . then ( function ( ) {
111+ wallaby . start ( ) ;
112+ } )
113+ . catch ( function ( e ) {
114+ setTimeout ( function ( ) {
115+ throw e ;
116+ } , 0 ) ;
117+ } ) ;
118+ }
119+ }
0 commit comments