File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,6 +76,8 @@ module.exports = function (grunt) {
7676 '<%= files.grunt %>' ,
7777 '<%= files.scripts %>' ,
7878 '<%= files.client %>' ,
79+ 'static/context.js' ,
80+ 'static/debug.js' ,
7981 'test/**/*.js' ,
8082 'gruntfile.js'
8183 ]
Original file line number Diff line number Diff line change @@ -114,8 +114,10 @@ var createKarmaMiddleware = function (
114114 } )
115115 }
116116
117- // serve karma.js
118- if ( requestUrl === '/karma.js' ) {
117+ // serve karma.js, context.js, and debug.js
118+ var jsFiles = [ '/karma.js' , '/context.js' , '/debug.js' ]
119+ var isRequestingJsFile = jsFiles . indexOf ( requestUrl ) !== - 1
120+ if ( isRequestingJsFile ) {
119121 return serveStaticFile ( requestUrl , response , function ( data ) {
120122 return data . replace ( '%KARMA_URL_ROOT%' , urlRoot )
121123 . replace ( '%KARMA_VERSION%' , VERSION )
@@ -195,11 +197,7 @@ var createKarmaMiddleware = function (
195197 return util . format ( " '%s': '%s'" , filePath , file . sha )
196198 } )
197199
198- var clientConfig = ''
199-
200- if ( requestUrl === '/debug.html' ) {
201- clientConfig = 'window.__karma__.config = ' + JSON . stringify ( client ) + ';\n'
202- }
200+ var clientConfig = 'window.__karma__.config = ' + JSON . stringify ( client ) + ';\n'
203201
204202 mappings = 'window.__karma__.files = {\n' + mappings . join ( ',\n' ) + '\n};\n'
205203
Original file line number Diff line number Diff line change 1515 to have already been created so they can insert their magic into it. For example, if loaded
1616 before body, Angular Scenario test framework fails to find the body and crashes and burns in
1717 an epic manner. -->
18+ < script src ="context.js "> </ script >
1819 < script type ="text/javascript ">
19- // sets window.__karma__ and overrides console and error handling
20- // Use window.opener if this was opened by someone else - in a new window
21- if ( window . opener ) {
22- window . opener . karma . setupContext ( window ) ;
23- } else {
24- window . parent . karma . setupContext ( window ) ;
25- }
20+ // Configure our Karma and set up bindings
21+ % CLIENT_CONFIG %
22+ window . __karma__ . setupContext ( window ) ;
2623
2724 // All served files with the latest timestamps
2825 % MAPPINGS %
Original file line number Diff line number Diff line change 1+ // Define a placeholder for Karma to be defined via the parent window
2+ // DEV: This is a placeholder change for upcoming edits in https://github.com/karma-runner/karma/pull/1984
3+ window . __karma__ = {
4+ setupContext : function ( contextWindow ) {
5+ // sets window.__karma__ and overrides console and error handling
6+ // Use window.opener if this was opened by someone else - in a new window
7+ if ( contextWindow . opener ) {
8+ contextWindow . opener . karma . setupContext ( contextWindow )
9+ } else {
10+ contextWindow . parent . karma . setupContext ( contextWindow )
11+ }
12+ }
13+ }
Original file line number Diff line number Diff line change 1717 (Angular Scenario, for example) need the body to be loaded so that it can insert its magic
1818 into it. If it is before body, then it fails to find the body and crashes and burns in an epic
1919 manner. -->
20+ < script src ="context.js "> </ script >
21+ < script src ="debug.js "> </ script >
2022 < script type ="text/javascript ">
21- window . __karma__ = {
22- info : function ( info ) {
23- if ( info . dump && window . console ) window . console . log ( info . dump ) ;
24- } ,
25- complete : function ( ) {
26- if ( window . console ) window . console . log ( 'Skipped ' + this . skipped + ' tests' ) ;
27- } ,
28- store : function ( ) { } ,
29- skipped : 0 ,
30- result : window . console ? function ( result ) {
31- if ( result . skipped ) {
32- this . skipped ++ ;
33- return ;
34- }
35- var msg = result . success ? 'SUCCESS ' : 'FAILED ' ;
36- window . console . log ( msg + result . suite . join ( ' ' ) + ' ' + result . description ) ;
37-
38- for ( var i = 0 ; i < result . log . length ; i ++ ) {
39- //throwing error without loosing stack trace
40- ( function ( err ) {
41- setTimeout ( function ( ) {
42- throw err ;
43- } ) ;
44- } ) ( result . log [ i ] )
45- }
46- } : function ( ) { } ,
47- loaded : function ( ) {
48- this . start ( ) ;
49- }
50- } ;
51-
23+ // Configure our Karma
5224 % CLIENT_CONFIG %
5325
5426 // All served files with the latest timestamps
Original file line number Diff line number Diff line change 1+ // Override the Karma setup for local debugging
2+ window . __karma__ . info = function ( info ) {
3+ if ( info . dump && window . console ) window . console . log ( info . dump )
4+ }
5+ window . __karma__ . complete = function ( ) {
6+ if ( window . console ) window . console . log ( 'Skipped ' + this . skipped + ' tests' )
7+ }
8+ window . __karma__ . store = function ( ) { }
9+ window . __karma__ . skipped = 0
10+ window . __karma__ . result = window . console ? function ( result ) {
11+ if ( result . skipped ) {
12+ this . skipped ++
13+ return
14+ }
15+ var msg = result . success ? 'SUCCESS ' : 'FAILED '
16+ window . console . log ( msg + result . suite . join ( ' ' ) + ' ' + result . description )
17+
18+ for ( var i = 0 ; i < result . log . length ; i ++ ) {
19+ // Throwing error without losing stack trace
20+ ( function ( err ) {
21+ setTimeout ( function ( ) {
22+ throw err
23+ } )
24+ } ) ( result . log [ i ] )
25+ }
26+ } : function ( ) { }
27+ window . __karma__ . loaded = function ( ) {
28+ this . start ( )
29+ }
Original file line number Diff line number Diff line change 1616 before body, Angular Scenario test framework fails to find the body and crashes and burns in
1717 an epic manner. -->
1818 < div id ="custom-context "> </ div >
19+ < script src ="context.js "> </ script >
1920 < script type ="text/javascript ">
20- // sets window.__karma__ and overrides console and error handling
21- // Use window.opener if this was opened by someone else - in a new window
22- if ( window . opener ) {
23- window . opener . karma . setupContext ( window ) ;
24- } else {
25- window . parent . karma . setupContext ( window ) ;
26- }
21+ // Configure our Karma and set up bindings
22+ % CLIENT_CONFIG %
23+ window . __karma__ . setupContext ( window ) ;
2724
2825 // All served files with the latest timestamps
2926 % MAPPINGS %
You can’t perform that action at this time.
0 commit comments