@@ -118,7 +118,7 @@ function pluginTester({
118118 teardowns . push ( returnedTeardown )
119119 }
120120 try {
121- tester ( )
121+ await tester ( )
122122 } finally {
123123 try {
124124 await Promise . all ( teardowns . map ( t => t ( ) ) )
@@ -132,7 +132,7 @@ function pluginTester({
132132 }
133133
134134 // eslint-disable-next-line complexity
135- function tester ( ) {
135+ async function tester ( ) {
136136 assert (
137137 code ,
138138 'A string or object with a `code` or `fixture` property must be provided' ,
@@ -146,16 +146,17 @@ function pluginTester({
146146 '`output` cannot be provided with `snapshot: true`' ,
147147 )
148148
149- let result
149+ let result , transformed
150150 let errored = false
151151
152152 try {
153+ if ( babel . transformAsync ) {
154+ transformed = await babel . transformAsync ( code , babelOptions )
155+ } else {
156+ transformed = babel . transform ( code , babelOptions )
157+ }
153158 result = formatResult (
154- fixLineEndings (
155- babel . transform ( code , babelOptions ) . code ,
156- endOfLine ,
157- code ,
158- ) ,
159+ fixLineEndings ( transformed . code , endOfLine , code ) ,
159160 { filename : testFilename } ,
160161 )
161162 } catch ( err ) {
@@ -293,7 +294,7 @@ const createFixtureTests = (fixturesDir, options) => {
293294 return
294295 }
295296
296- it ( blockTitle , ( ) => {
297+ it ( blockTitle , async ( ) => {
297298 const {
298299 plugin,
299300 pluginOptions,
@@ -335,17 +336,23 @@ const createFixtureTests = (fixturesDir, options) => {
335336 )
336337
337338 const input = fs . readFileSync ( codePath ) . toString ( )
339+ let transformed , ext
340+ if ( babel . transformAsync ) {
341+ transformed = await babel . transformAsync ( input , {
342+ ...babelOptions ,
343+ filename : codePath ,
344+ } )
345+ } else {
346+ transformed = babel . transform ( input , {
347+ ...babelOptions ,
348+ filename : codePath ,
349+ } )
350+ }
338351 const actual = formatResult (
339- fixLineEndings (
340- babel . transformSync ( input , { ...babelOptions , filename : codePath } )
341- . code ,
342- endOfLine ,
343- input ,
344- ) ,
352+ fixLineEndings ( transformed . code , endOfLine , input ) ,
345353 )
346354
347355 const { fixtureOutputExt} = fixturePluginOptions
348- let ext
349356 if ( fixtureOutputExt ) {
350357 ext = fixtureOutputExt
351358 } else {
0 commit comments