@@ -66,7 +66,7 @@ module.exports = Api;
66
66
67
67
Api . prototype . _runFile = function ( file , runStatus , execArgv ) {
68
68
var hash = this . precompiler . precompileFile ( file ) ;
69
- var precompiled = { } ;
69
+ var precompiled = objectAssign ( { } , this . _precompiledHelpers ) ;
70
70
precompiled [ file ] = hash ;
71
71
72
72
var options = objectAssign ( { } , this . options , {
@@ -134,7 +134,22 @@ Api.prototype._setupPrecompiler = function (files) {
134
134
} ) ;
135
135
} ;
136
136
137
+ Api . prototype . _precompileHelpers = function ( ) {
138
+ var self = this ;
139
+
140
+ this . _precompiledHelpers = { } ;
141
+
142
+ return new AvaFiles ( { cwd : this . options . resolveTestsFrom } )
143
+ . findTestHelpers ( )
144
+ . map ( function ( file ) { // eslint-disable-line array-callback-return
145
+ var hash = self . precompiler . precompileFile ( file ) ;
146
+ self . _precompiledHelpers [ file ] = hash ;
147
+ } ) ;
148
+ } ;
149
+
137
150
Api . prototype . _run = function ( files , options ) {
151
+ var self = this ;
152
+
138
153
options = options || { } ;
139
154
140
155
var runStatus = new RunStatus ( {
@@ -154,20 +169,23 @@ Api.prototype._run = function (files, options) {
154
169
155
170
this . _setupPrecompiler ( files ) ;
156
171
157
- if ( this . options . timeout ) {
158
- this . _setupTimeout ( runStatus ) ;
159
- }
172
+ return this . _precompileHelpers ( )
173
+ . then ( function ( ) {
174
+ if ( self . options . timeout ) {
175
+ self . _setupTimeout ( runStatus ) ;
176
+ }
160
177
161
- var overwatch ;
162
- if ( this . options . concurrency > 0 ) {
163
- var concurrency = this . options . serial ? 1 : this . options . concurrency ;
164
- overwatch = this . _runWithPool ( files , runStatus , concurrency ) ;
165
- } else {
166
- // _runWithoutPool exists to preserve legacy behavior, specifically around `.only`
167
- overwatch = this . _runWithoutPool ( files , runStatus ) ;
168
- }
178
+ var overwatch ;
179
+ if ( self . options . concurrency > 0 ) {
180
+ var concurrency = self . options . serial ? 1 : self . options . concurrency ;
181
+ overwatch = self . _runWithPool ( files , runStatus , concurrency ) ;
182
+ } else {
183
+ // _runWithoutPool exists to preserve legacy behavior, specifically around `.only`
184
+ overwatch = self . _runWithoutPool ( files , runStatus ) ;
185
+ }
169
186
170
- return overwatch ;
187
+ return overwatch ;
188
+ } ) ;
171
189
} ;
172
190
173
191
Api . prototype . _computeForkExecArgs = function ( files ) {
0 commit comments