@@ -249,6 +249,62 @@ describe('transformWithEsbuild', () => {
249
249
expect ( result ?. code ) . toBeTruthy ( )
250
250
expect ( result ?. map ) . toBeTruthy ( )
251
251
} )
252
+
253
+ test ( 'correctly overrides TS configuration and applies automatic transform' , async ( ) => {
254
+ const jsxImportSource = 'bar'
255
+ const result = await transformWithEsbuild (
256
+ 'const foo = () => <></>' ,
257
+ 'baz.jsx' ,
258
+ {
259
+ tsconfigRaw : {
260
+ compilerOptions : {
261
+ jsx : 'preserve' ,
262
+ } ,
263
+ } ,
264
+ jsx : 'automatic' ,
265
+ jsxImportSource,
266
+ } ,
267
+ )
268
+ expect ( result ?. code ) . toContain ( `${ jsxImportSource } /jsx-runtime` )
269
+ expect ( result ?. code ) . toContain ( '/* @__PURE__ */' )
270
+ } )
271
+
272
+ test ( 'correctly overrides TS configuration and preserves code' , async ( ) => {
273
+ const foo = 'const foo = () => <></>'
274
+ const result = await transformWithEsbuild ( foo , 'baz.jsx' , {
275
+ tsconfigRaw : {
276
+ compilerOptions : {
277
+ jsx : 'react-jsx' ,
278
+ } ,
279
+ } ,
280
+ jsx : 'preserve' ,
281
+ } )
282
+ expect ( result ?. code ) . toContain ( foo )
283
+ } )
284
+
285
+ test ( 'correctly overrides TS configuration and transforms code' , async ( ) => {
286
+ const jsxFactory = 'h' ,
287
+ jsxFragment = 'bar'
288
+ const result = await transformWithEsbuild (
289
+ 'const foo = () => <></>' ,
290
+ 'baz.jsx' ,
291
+ {
292
+ tsconfigRaw : {
293
+ compilerOptions : {
294
+ jsxFactory : 'g' ,
295
+ jsxFragmentFactory : 'foo' ,
296
+ jsxImportSource : 'baz' ,
297
+ } ,
298
+ } ,
299
+ jsx : 'transform' ,
300
+ jsxFactory,
301
+ jsxFragment,
302
+ } ,
303
+ )
304
+ expect ( result ?. code ) . toContain (
305
+ `/* @__PURE__ */ ${ jsxFactory } (${ jsxFragment } , null)` ,
306
+ )
307
+ } )
252
308
} )
253
309
254
310
/**
0 commit comments