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