@@ -15,6 +15,11 @@ type TestQuestion = {
1515 default ?: any ;
1616} ;
1717
18+ type PromptCalls = {
19+ question : TestQuestion ;
20+ answer : any ;
21+ } ;
22+
1823export type DummyPromptCallback = ( answer : any , { question, answers } : { question : TestQuestion ; answers : PromptAnswers } ) => any ;
1924
2025export type DummyPromptOptions = {
@@ -47,7 +52,7 @@ const isValueSet = (type: string, answer: any) => {
4752 return Boolean ( answer ) ;
4853} ;
4954
50- const createDummyPrompt = ( options : DummyPromptOptions = { } ) => {
55+ const createDummyPrompt = ( { calls } : { calls : PromptCalls [ ] } , options : DummyPromptOptions = { } ) => {
5156 const { mockedAnswers = { } , callback = answer => answer , throwOnMissingAnswer = false } = options ;
5257 return createPrompt < any , TestQuestion > ( ( config , done ) => {
5358 let answer = mockedAnswers [ config . name ! ] ;
@@ -68,6 +73,7 @@ const createDummyPrompt = (options: DummyPromptOptions = {}) => {
6873 answer = true ;
6974 }
7075 }
76+ calls . push ( { question : config , answer } ) ;
7177 done ( callback ( answer , { question : config , answers : { [ config . name ] : answer } } ) ) ;
7278
7379 return config . message ;
@@ -87,6 +93,7 @@ export class TestAdapter<LogType extends Logger = Logger, SpyType = any> impleme
8793 log : LogType & SpyType ;
8894 registerDummyPrompt : ( promptName : string , customPromptOptions ?: DummyPromptOptions ) => PromptModule ;
8995 readonly mockedAnswers : PromptAnswers ;
96+ readonly calls : PromptCalls [ ] = [ ] ;
9097
9198 private abortController = new AbortController ( ) ;
9299 private readonly spyFactory : SpyFactory < SpyType > ;
@@ -107,7 +114,6 @@ export class TestAdapter<LogType extends Logger = Logger, SpyType = any> impleme
107114 skipTTYChecks : true ,
108115 signal : this . abortController . signal ,
109116 } ) ;
110-
111117 this . mockedAnswers = { } ;
112118 this . addAnswers ( mockedAnswers ?? { } ) ;
113119
@@ -116,7 +122,10 @@ export class TestAdapter<LogType extends Logger = Logger, SpyType = any> impleme
116122 this . registerDummyPrompt = ( promptModuleName : string , customPromptOptions ?: DummyPromptOptions ) =>
117123 actualRegisterPrompt (
118124 promptModuleName ,
119- createDummyPrompt ( { callback, mockedAnswers : this . mockedAnswers , throwOnMissingAnswer, ...customPromptOptions } ) ,
125+ createDummyPrompt (
126+ { calls : this . calls } ,
127+ { callback, mockedAnswers : this . mockedAnswers , throwOnMissingAnswer, ...customPromptOptions } ,
128+ ) ,
120129 ) ;
121130
122131 this . promptModule . registerPrompt = ( name : string ) => this . registerDummyPrompt ( name ) ;
0 commit comments