@@ -306,11 +306,14 @@ test('can pass tests in fixtures relative to the filename', async () => {
306306 } ) ,
307307 )
308308 expect ( describeSpy ) . toHaveBeenCalledTimes ( 5 )
309- expect ( itSpy ) . toHaveBeenCalledTimes ( 8 )
309+ expect ( itSpy ) . toHaveBeenCalledTimes ( 10 )
310+
310311 expect ( itSpy . mock . calls ) . toEqual ( [
311312 [ `changed` , expect . any ( Function ) ] ,
313+ [ `jsx support` , expect . any ( Function ) ] ,
312314 [ `nested a` , expect . any ( Function ) ] ,
313315 [ `nested b` , expect . any ( Function ) ] ,
316+ [ `tsx support` , expect . any ( Function ) ] ,
314317 [ `typescript` , expect . any ( Function ) ] ,
315318 [ `unchanged` , expect . any ( Function ) ] ,
316319 [ `nested with option` , expect . any ( Function ) ] ,
@@ -342,10 +345,21 @@ test('creates output file for new tests', async () => {
342345 } ) ,
343346 )
344347
345- expect ( writeFileSyncSpy . mock . calls [ 0 ] ) . toEqual ( [
346- expect . stringMatching ( / ( \/ | \\ ) o u t p u t \. ( j | t ) s $ / ) ,
347- "'use strict';" ,
348- ] )
348+ const calls = writeFileSyncSpy . mock . calls [ 0 ]
349+ const outputMatch = / ( \/ | \\ ) o u t p u t \. ( j | t ) s x ? $ /
350+ if ( calls [ 0 ] . endsWith ( '.jsx' ) ) {
351+ expect ( calls ) . toEqual ( [
352+ expect . stringMatching ( outputMatch ) ,
353+ 'export default <div></div>;' ,
354+ ] )
355+ } else if ( calls [ 0 ] . endsWith ( '.tsx' ) ) {
356+ expect ( calls ) . toEqual ( [
357+ expect . stringMatching ( outputMatch ) ,
358+ 'export default <div></div> as any;' ,
359+ ] )
360+ } else {
361+ expect ( calls ) . toEqual ( [ expect . stringMatching ( outputMatch ) , "'use strict';" ] )
362+ }
349363} )
350364
351365test ( 'uses the fixture filename in babelOptions' , async ( ) => {
@@ -614,7 +628,7 @@ test('allows formatting fixtures results', async () => {
614628 formatResult : formatResultSpy ,
615629 } ) ,
616630 )
617- expect ( formatResultSpy ) . toHaveBeenCalledTimes ( 9 )
631+ expect ( formatResultSpy ) . toHaveBeenCalledTimes ( 11 )
618632} )
619633
620634test ( 'works with a formatter adding a empty line' , async ( ) => {
@@ -626,7 +640,7 @@ test('works with a formatter adding a empty line', async () => {
626640 formatResult : formatResultSpy ,
627641 } ) ,
628642 )
629- expect ( formatResultSpy ) . toHaveBeenCalledTimes ( 9 )
643+ expect ( formatResultSpy ) . toHaveBeenCalledTimes ( 11 )
630644} )
631645
632646test ( 'gets options from options.json files when using fixtures' , async ( ) => {
@@ -658,7 +672,7 @@ test('gets options from options.json files when using fixtures', async () => {
658672 } ) ,
659673 )
660674
661- expect ( optionRootFoo ) . toHaveBeenCalledTimes ( 8 )
675+ expect ( optionRootFoo ) . toHaveBeenCalledTimes ( 10 )
662676 expect ( optionFoo ) . toHaveBeenCalledTimes ( 2 )
663677 expect ( optionBar ) . toHaveBeenCalledTimes ( 1 )
664678} )
@@ -703,10 +717,10 @@ test('appends to root plugins array', async () => {
703717 } ) ,
704718 )
705719
706- expect ( optionRootFoo ) . toHaveBeenCalledTimes ( 8 )
720+ expect ( optionRootFoo ) . toHaveBeenCalledTimes ( 10 )
707721 expect ( optionFoo ) . toHaveBeenCalledTimes ( 2 )
708722 expect ( optionBar ) . toHaveBeenCalledTimes ( 1 )
709- expect ( programVisitor ) . toHaveBeenCalledTimes ( 9 )
723+ expect ( programVisitor ) . toHaveBeenCalledTimes ( 11 )
710724} )
711725
712726test ( 'endOfLine - default' , async ( ) => {
0 commit comments