@@ -176,7 +176,7 @@ describe('Watch mode flows', () => {
176176 await watch (
177177 Object . assign ( { } , globalConfig , {
178178 rootDir : __dirname ,
179- watchPlugins : [ watchPluginPath ] ,
179+ watchPlugins : [ { config : { } , path : watchPluginPath } ] ,
180180 } ) ,
181181 contexts ,
182182 pipe ,
@@ -195,7 +195,10 @@ describe('Watch mode flows', () => {
195195 ci_watch (
196196 Object . assign ( { } , globalConfig , {
197197 rootDir : __dirname ,
198- watchPlugins : [ watchPlugin2Path , watchPluginPath ] ,
198+ watchPlugins : [
199+ { config : { } , path : watchPluginPath } ,
200+ { config : { } , path : watchPlugin2Path } ,
201+ ] ,
199202 } ) ,
200203 contexts ,
201204 pipe ,
@@ -302,7 +305,7 @@ describe('Watch mode flows', () => {
302305 watch (
303306 Object . assign ( { } , globalConfig , {
304307 rootDir : __dirname ,
305- watchPlugins : [ pluginPath ] ,
308+ watchPlugins : [ { config : { } , path : pluginPath } ] ,
306309 } ) ,
307310 contexts ,
308311 pipe ,
@@ -338,7 +341,7 @@ describe('Watch mode flows', () => {
338341 watch (
339342 Object . assign ( { } , globalConfig , {
340343 rootDir : __dirname ,
341- watchPlugins : [ pluginPath ] ,
344+ watchPlugins : [ { config : { } , path : pluginPath } ] ,
342345 } ) ,
343346 contexts ,
344347 pipe ,
@@ -356,6 +359,47 @@ describe('Watch mode flows', () => {
356359 expect ( run ) . toHaveBeenCalled ( ) ;
357360 } ) ;
358361
362+ it ( 'allows WatchPlugins to be configured' , async ( ) => {
363+ const pluginPath = `${ __dirname } /__fixtures__/plugin_path_with_config` ;
364+ jest . doMock (
365+ pluginPath ,
366+ ( ) =>
367+ class WatchPlugin {
368+ constructor ( { config} ) {
369+ this . _key = config . key ;
370+ this . _prompt = config . prompt ;
371+ }
372+ onKey ( ) { }
373+ run ( ) { }
374+ getUsageInfo ( ) {
375+ return {
376+ key : this . _key || 'z' ,
377+ prompt : this . _prompt || 'default prompt' ,
378+ } ;
379+ }
380+ } ,
381+ { virtual : true } ,
382+ ) ;
383+
384+ watch (
385+ Object . assign ( { } , globalConfig , {
386+ rootDir : __dirname ,
387+ watchPlugins : [
388+ {
389+ config : { key : 'k' , prompt : 'filter with a custom prompt' } ,
390+ path : pluginPath ,
391+ } ,
392+ ] ,
393+ } ) ,
394+ contexts ,
395+ pipe ,
396+ hasteMapInstances ,
397+ stdin ,
398+ ) ;
399+
400+ expect ( pipe . write . mock . calls . reverse ( ) [ 0 ] ) . toMatchSnapshot ( ) ;
401+ } ) ;
402+
359403 it ( 'allows WatchPlugins to hook into file system changes' , async ( ) => {
360404 const onFileChange = jest . fn ( ) ;
361405 const pluginPath = `${ __dirname } /__fixtures__/plugin_path_fs_change` ;
@@ -373,7 +417,7 @@ describe('Watch mode flows', () => {
373417 watch (
374418 Object . assign ( { } , globalConfig , {
375419 rootDir : __dirname ,
376- watchPlugins : [ pluginPath ] ,
420+ watchPlugins : [ { config : { } , path : pluginPath } ] ,
377421 } ) ,
378422 contexts ,
379423 pipe ,
@@ -414,7 +458,7 @@ describe('Watch mode flows', () => {
414458 watch (
415459 Object . assign ( { } , globalConfig , {
416460 rootDir : __dirname ,
417- watchPlugins : [ pluginPath ] ,
461+ watchPlugins : [ { config : { } , path : pluginPath } ] ,
418462 } ) ,
419463 contexts ,
420464 pipe ,
@@ -474,7 +518,10 @@ describe('Watch mode flows', () => {
474518 watch (
475519 Object . assign ( { } , globalConfig , {
476520 rootDir : __dirname ,
477- watchPlugins : [ pluginPath , pluginPath2 ] ,
521+ watchPlugins : [
522+ { config : { } , path : pluginPath } ,
523+ { config : { } , path : pluginPath2 } ,
524+ ] ,
478525 } ) ,
479526 contexts ,
480527 pipe ,
0 commit comments