@@ -164,9 +164,35 @@ describe("plugin command", () => {
164164
165165 it ( "should prompt on supplying an invalid template" , async ( ) => {
166166 const assetsPath = await uniqueDirectoryForTest ( ) ;
167- const { stderr } = await runPromptWithAnswers ( assetsPath , [ "plugin" , "--template=unknown" ] ) ;
167+ const { defaultPluginPath, defaultTemplateFiles } = dataForTests ( assetsPath ) ;
168+ let { stdout, stderr } = await runPromptWithAnswers (
169+ assetsPath ,
170+ [ "plugin" , "--template=unknown" ] ,
171+ [ ENTER , ENTER , ENTER ] ,
172+ ) ;
168173
169174 expect ( stderr ) . toContain ( "unknown is not a valid template" ) ;
175+ expect ( normalizeStdout ( stdout ) ) . toContain ( firstPrompt ) ;
176+
177+ // Check if the output directory exists with the appropriate plugin name
178+ expect ( existsSync ( defaultPluginPath ) ) . toBeTruthy ( ) ;
179+
180+ // Skip test in case installation fails
181+ if ( ! existsSync ( resolve ( defaultPluginPath , "./package-lock.json" ) ) ) {
182+ return ;
183+ }
184+
185+ // Test regressively files are scaffolded
186+ for ( const file of defaultTemplateFiles ) {
187+ expect ( existsSync ( join ( defaultPluginPath , file ) ) ) . toBeTruthy ( ) ;
188+ }
189+
190+ // Check if the generated plugin works successfully
191+ ( { stdout } = await run ( defaultPluginPath , [
192+ "--config" ,
193+ "./examples/simple/webpack.config.js" ,
194+ ] ) ) ;
195+ expect ( normalizeStdout ( stdout ) ) . toContain ( "Hello World!" ) ;
170196 } ) ;
171197
172198 it ( "recognizes '-t' as an alias for '--template'" , async ( ) => {
0 commit comments