This repository was archived by the owner on Oct 1, 2020. It is now read-only.
File tree 2 files changed +21
-9
lines changed
2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -149,20 +149,22 @@ const preprocessor = (options = {}) => {
149
149
latestBundle = createDeferred ( )
150
150
bundles [ filePath ] = latestBundle . promise . tap ( ( ) => {
151
151
log ( '- compile finished for' , filePath )
152
- // when the bundling is finished, we call `util.fileUpdated`
153
- // to let Cypress know to re-run the spec
152
+ // when the bundling is finished, emit 'rerun' to let Cypress
153
+ // know to rerun the spec
154
154
file . emit ( 'rerun' )
155
155
} )
156
156
}
157
157
158
- if ( compiler . hooks ) {
159
- compiler . hooks . compile . tap ( plugin , onCompile )
160
- } else {
161
- compiler . plugin ( 'compile' , onCompile )
162
- }
163
-
158
+ // when we should watch, we hook into the 'compile' hook so we know when
159
+ // to rerun the tests
164
160
if ( file . shouldWatch ) {
165
161
log ( 'watching' )
162
+
163
+ if ( compiler . hooks ) {
164
+ compiler . hooks . compile . tap ( plugin , onCompile )
165
+ } else {
166
+ compiler . plugin ( 'compile' , onCompile )
167
+ }
166
168
}
167
169
168
170
const bundler = file . shouldWatch ? compiler . watch ( watchOptions , handle ) : compiler . run ( handle )
Original file line number Diff line number Diff line change @@ -142,13 +142,23 @@ describe('webpack preprocessor', function () {
142
142
} )
143
143
} )
144
144
145
- it ( 'emits `rerun` when there is an update' , function ( ) {
145
+ it ( 'emits "rerun" when shouldWatch is true and there is an update' , function ( ) {
146
+ this . file . shouldWatch = true
147
+ this . compilerApi . watch . yields ( null , this . statsApi )
146
148
this . compilerApi . plugin . withArgs ( 'compile' ) . yields ( )
147
149
return this . run ( ) . then ( ( ) => {
148
150
expect ( this . file . emit ) . to . be . calledWith ( 'rerun' )
149
151
} )
150
152
} )
151
153
154
+ it ( 'does not emit "rerun" when shouldWatch is false' , function ( ) {
155
+ this . file . shouldWatch = false
156
+ this . compilerApi . plugin . withArgs ( 'compile' ) . yields ( )
157
+ return this . run ( ) . then ( ( ) => {
158
+ expect ( this . file . emit ) . not . to . be . calledWith ( 'rerun' )
159
+ } )
160
+ } )
161
+
152
162
it ( 'closes bundler when shouldWatch is true and `close` is emitted' , function ( ) {
153
163
this . file . shouldWatch = true
154
164
this . compilerApi . watch . yields ( null , this . statsApi )
You can’t perform that action at this time.
0 commit comments