@@ -8,8 +8,10 @@ const path = require('node:path');
88const { rollup } = require ( '../../dist/rollup' ) ;
99const {
1010 compareLogs,
11+ getRandomElement,
1112 normaliseOutput,
1213 runTestSuiteWithSamples,
14+ shuffle,
1315 verifyAstPlugin
1416} = require ( '../testHelpers.js' ) ;
1517
@@ -29,9 +31,9 @@ runTestSuiteWithSamples(
2931 ( ) => {
3032 let bundle ;
3133 const logs = [ ] ;
34+ const warnings = [ ] ;
3235
3336 const runRollupTest = async ( inputFile , bundleFile , format , fromCache ) => {
34- const warnings = [ ] ;
3537 if ( config . before ) {
3638 await config . before ( ) ;
3739 }
@@ -83,10 +85,11 @@ runTestSuiteWithSamples(
8385 for ( const { code } of warnings ) {
8486 codes . add ( code ) ;
8587 }
88+ const messages = warnings . map ( ( { message } ) => `${ message } \n\n` ) . join ( '' ) ;
89+ warnings . length = 0 ;
8690 throw new Error (
87- `Unexpected warnings (${ [ ...codes ] . join ( ', ' ) } ): \n${ warnings
88- . map ( ( { message } ) => `${ message } \n\n` )
89- . join ( '' ) } ` + 'If you expect warnings, list their codes in config.expectedWarnings'
91+ `Unexpected warnings (${ [ ...codes ] . join ( ', ' ) } ): \n${ messages } ` +
92+ 'If you expect warnings, list their codes in config.expectedWarnings'
9093 ) ;
9194 }
9295 } ;
@@ -101,7 +104,8 @@ runTestSuiteWithSamples(
101104 . then ( ( ) => config . logs && compareLogs ( logs , config . logs ) ) ;
102105 }
103106
104- for ( const format of config . formats || FORMATS ) {
107+ const formats = shuffle ( config . formats || FORMATS ) ;
108+ for ( const format of formats ) {
105109 after ( ( ) => config . logs && compareLogs ( logs , config . logs ) ) ;
106110
107111 it ( `generates ${ format } ` , ( ) =>
@@ -113,13 +117,13 @@ runTestSuiteWithSamples(
113117 ) ) ;
114118 }
115119
116- const format = ( config . formats || FORMATS ) [ 0 ] ;
120+ const format = getRandomElement ( formats ) ;
117121 it ( `generates ${ format } from the cache` , ( ) =>
118122 runRollupTest (
119123 `${ directory } /_actual/${ format } .js` ,
120124 `${ directory } /_expected/${ format } .js` ,
121125 format ,
122- false
126+ true
123127 ) ) ;
124128 }
125129 ) ;
0 commit comments