@@ -157,22 +157,24 @@ describe("asynchronicity", () => {
157157 expect ( ( ) =>
158158 babel . transformSync ( "" ) ,
159159 ) . toThrowErrorMatchingInlineSnapshot (
160- `"unknown file: You appear to be using an plugin with an async .pre, which your current version` +
161- ` of Babel does not support. If you're using a published plugin, you may need to upgrade your` +
162- ` @babel/core version."` ,
160+ `"unknown file: You appear to be using an async plugin/preset, but Babel has been called synchronously"` ,
163161 ) ;
164162 } ) ;
165163
166164 nodeGte8 ( "called asynchronously" , async ( ) => {
167165 process . chdir ( "plugin-pre" ) ;
168166
169- await expect (
170- babel . transformAsync ( "" ) ,
171- ) . rejects . toThrowErrorMatchingInlineSnapshot (
172- `"unknown file: You appear to be using an plugin with an async .pre, which your current version` +
173- ` of Babel does not support. If you're using a published plugin, you may need to upgrade your` +
174- ` @babel/core version."` ,
175- ) ;
167+ await expect ( babel . transformAsync ( "" ) ) . resolves . toMatchObject ( {
168+ code : `"success"` ,
169+ } ) ;
170+ } ) ;
171+
172+ nodeGte8 ( "should await inherited .pre" , async ( ) => {
173+ process . chdir ( "plugin-pre-chaining" ) ;
174+
175+ await expect ( babel . transformAsync ( "" ) ) . resolves . toMatchObject ( {
176+ code : `"pluginC,pluginB,pluginA"` ,
177+ } ) ;
176178 } ) ;
177179 } ) ;
178180
@@ -183,22 +185,50 @@ describe("asynchronicity", () => {
183185 expect ( ( ) =>
184186 babel . transformSync ( "" ) ,
185187 ) . toThrowErrorMatchingInlineSnapshot (
186- `"unknown file: You appear to be using an plugin with an async .post, which your current version` +
187- ` of Babel does not support. If you're using a published plugin, you may need to upgrade your` +
188- ` @babel/core version."` ,
188+ `"unknown file: You appear to be using an async plugin/preset, but Babel has been called synchronously"` ,
189189 ) ;
190190 } ) ;
191191
192192 nodeGte8 ( "called asynchronously" , async ( ) => {
193193 process . chdir ( "plugin-post" ) ;
194194
195- await expect (
196- babel . transformAsync ( "" ) ,
197- ) . rejects . toThrowErrorMatchingInlineSnapshot (
198- `"unknown file: You appear to be using an plugin with an async .post, which your current version` +
199- ` of Babel does not support. If you're using a published plugin, you may need to upgrade your` +
200- ` @babel/core version."` ,
201- ) ;
195+ await expect ( babel . transformAsync ( "" ) ) . resolves . toMatchObject ( {
196+ code : `"success"` ,
197+ } ) ;
198+ } ) ;
199+
200+ nodeGte8 ( "should await inherited .post" , async ( ) => {
201+ process . chdir ( "plugin-post-chaining" ) ;
202+
203+ await expect ( babel . transformAsync ( "" ) ) . resolves . toMatchObject ( {
204+ code : `"pluginC,pluginB,pluginA"` ,
205+ } ) ;
206+ } ) ;
207+ } ) ;
208+
209+ describe ( "PluginPass.isAsync" , ( ) => {
210+ nodeGte8 ( "called synchronously" , ( ) => {
211+ process . chdir ( "plugin-pass-is-async" ) ;
212+
213+ expect ( babel . transformSync ( "" ) ) . toMatchObject ( {
214+ code : `"sync"` ,
215+ } ) ;
216+ } ) ;
217+
218+ nodeGte8 ( "called asynchronously" , async ( ) => {
219+ process . chdir ( "plugin-pass-is-async" ) ;
220+
221+ await expect ( babel . transformAsync ( "" ) ) . resolves . toMatchObject ( {
222+ code : `"async"` ,
223+ } ) ;
224+ } ) ;
225+
226+ nodeGte8 ( "should await inherited .pre" , async ( ) => {
227+ process . chdir ( "plugin-pre-chaining" ) ;
228+
229+ await expect ( babel . transformAsync ( "" ) ) . resolves . toMatchObject ( {
230+ code : `"pluginC,pluginB,pluginA"` ,
231+ } ) ;
202232 } ) ;
203233 } ) ;
204234
@@ -350,7 +380,7 @@ describe("asynchronicity", () => {
350380 } ) ;
351381
352382 describe ( "misc" , ( ) => {
353- it ( "unknown preset in config file does not trigget unhandledRejection if caught" , async ( ) => {
383+ it ( "unknown preset in config file does not trigger unhandledRejection if caught" , async ( ) => {
354384 process . chdir ( "unknown-preset" ) ;
355385 const handler = jest . fn ( ) ;
356386
0 commit comments