@@ -55,25 +55,25 @@ test('basic', async () => {
5555 transformer : [ ] ,
5656 parserOptions : { } ,
5757 }
58- let code = ( await transform ( source , 'foo.js' , options ) ) ?. code
58+ let code = ( await transform ( source , 'foo.js' , options ) ) ?. toString ( )
5959 expect ( code ) . toMatchInlineSnapshot ( 'undefined' )
6060
6161 options . transformer = [ changeString ]
62- code = ( await transform ( source , 'foo.js' , options ) ) ?. code
62+ code = ( await transform ( source , 'foo.js' , options ) ) ?. toString ( )
6363 expect ( code ) . toMatchInlineSnapshot ( `
6464 "const foo = 'Hello'
6565 let i = 10"
6666 ` )
6767
6868 options . transformer = [ changeVarName ]
69- code = ( await transform ( source , 'foo.js' , options ) ) ?. code
69+ code = ( await transform ( source , 'foo.js' , options ) ) ?. toString ( )
7070 expect ( code ) . toMatchInlineSnapshot ( `
7171 "const newName = 'string'
7272 let i = 10"
7373 ` )
7474
7575 options . transformer = [ changeString , changeVarName ]
76- code = ( await transform ( source , 'foo.js' , options ) ) ?. code
76+ code = ( await transform ( source , 'foo.js' , options ) ) ?. toString ( )
7777 expect ( code ) . toMatchInlineSnapshot ( `
7878 "const newName = 'Hello'
7979 let i = 10"
@@ -87,14 +87,14 @@ test('change twice', async () => {
8787 parserOptions : { } ,
8888 }
8989 options . transformer = [ changeString , changeVarName , overwriteVarName ]
90- let code = ( await transform ( source , 'foo.js' , options ) ) ?. code
90+ let code = ( await transform ( source , 'foo.js' , options ) ) ?. toString ( )
9191 expect ( code ) . toMatchInlineSnapshot ( `
9292 "const overwrite_newName = 'Hello'
9393 let overwrite_i = 10"
9494 ` )
9595
9696 options . transformer = [ timesTen , timesTen , timesTen ]
97- code = ( await transform ( source , 'foo.js' , options ) ) ?. code
97+ code = ( await transform ( source , 'foo.js' , options ) ) ?. toString ( )
9898 expect ( code ) . toMatchInlineSnapshot ( `
9999 "const foo = 'string'
100100 let i = 10000"
@@ -108,7 +108,7 @@ test('remove node', async () => {
108108 parserOptions : { } ,
109109 }
110110 options . transformer = [ removeFirstStatement ]
111- const code = ( await transform ( source , 'foo.js' , options ) ) ?. code
111+ const code = ( await transform ( source , 'foo.js' , options ) ) ?. toString ( )
112112 expect ( code ) . toMatchInlineSnapshot ( `
113113 "
114114 let i = 10;{}"
@@ -147,7 +147,7 @@ test('transform with Yuku AST', async () => {
147147 ] ,
148148 parserOptions : { } ,
149149 }
150- const code = ( await transform ( source , 'foo.js' , options ) ) ?. code
150+ const code = ( await transform ( source , 'foo.js' , options ) ) ?. toString ( )
151151 expect ( code ) . toBe ( 'const overwrite_renamed = 1' )
152152} )
153153
@@ -157,7 +157,7 @@ test('handles Unicode offsets', async () => {
157157 transformer : [ changeVarName ] ,
158158 parserOptions : { } ,
159159 }
160- const code = ( await transform ( source , 'foo.js' , options ) ) ?. code
160+ const code = ( await transform ( source , 'foo.js' , options ) ) ?. toString ( )
161161 expect ( code ) . toBe ( `const 文 = '值'\nconst newName = 'string'` )
162162} )
163163
@@ -168,7 +168,7 @@ test('detects language through query parameters', async () => {
168168 parserOptions : { } ,
169169 }
170170 for ( const id of [ 'foo.ts?raw' , 'foo.vue?vue&type=script&lang.ts' ] ) {
171- const code = ( await transform ( source , id , options ) ) ?. code
171+ const code = ( await transform ( source , id , options ) ) ?. toString ( )
172172 expect ( code ) . toBe ( `const foo: string = 'Hello'` )
173173 }
174174} )
@@ -190,7 +190,7 @@ test.fails('overwrite part', async () => {
190190 parserOptions : { } ,
191191 }
192192 expect (
193- ( await transform ( source , 'foo.js' , options ) ) ?. code ,
193+ ( await transform ( source , 'foo.js' , options ) ) ?. toString ( ) ,
194194 ) . toMatchInlineSnapshot ( 'undefined' )
195195} )
196196
@@ -209,7 +209,7 @@ test('rewrite statement', async () => {
209209 } ,
210210 } ,
211211 ]
212- const code = ( await transform ( source , 'foo.js' , options ) ) ?. code
212+ const code = ( await transform ( source , 'foo.js' , options ) ) ?. toString ( )
213213 expect ( code ) . toMatchInlineSnapshot ( `
214214 "const foo = 'bar'; const bar = 'foo'
215215 let i = 10;{i++}"
0 commit comments