@@ -245,18 +245,15 @@ test('can get a code and output fixture that is an absolute path', async () => {
245
245
outputFixture : getFixturePath ( 'outure1.js' ) ,
246
246
} ,
247
247
]
248
- try {
249
- await runPluginTester ( getOptions ( { tests} ) )
250
- } catch ( error ) {
251
- const actual = getFixtureContents ( 'fixture1.js' )
252
- const expected = getFixtureContents ( 'outure1.js' )
253
- expect ( error ) . toMatchObject ( {
254
- name : expect . stringMatching ( / A s s e r t i o n E r r o r / ) ,
255
- message : 'Output is incorrect.' ,
256
- actual,
257
- expected,
258
- } )
259
- }
248
+ const error = await runPluginTester ( getOptions ( { tests} ) ) . catch ( e => e )
249
+ const actual = getFixtureContents ( 'fixture1.js' )
250
+ const expected = getFixtureContents ( 'outure1.js' )
251
+ expect ( error ) . toMatchObject ( {
252
+ name : expect . stringMatching ( / A s s e r t i o n E r r o r / ) ,
253
+ message : 'Output is incorrect.' ,
254
+ actual,
255
+ expected,
256
+ } )
260
257
} )
261
258
262
259
test ( 'can pass with fixture and outputFixture' , async ( ) => {
@@ -283,18 +280,17 @@ test('can resolve a fixture with the filename option', async () => {
283
280
outputFixture : 'fixtures/outure1.js' ,
284
281
} ,
285
282
]
286
- try {
287
- await runPluginTester ( getOptions ( { filename : __filename , tests} ) )
288
- } catch ( error ) {
289
- const actual = getFixtureContents ( 'fixture1.js' )
290
- const expected = getFixtureContents ( 'outure1.js' )
291
- expect ( error ) . toMatchObject ( {
292
- name : expect . stringMatching ( / A s s e r t i o n E r r o r / ) ,
293
- message : 'Output is incorrect.' ,
294
- actual,
295
- expected,
296
- } )
297
- }
283
+ const error = await runPluginTester (
284
+ getOptions ( { filename : __filename , tests} ) ,
285
+ ) . catch ( e => e )
286
+ const actual = getFixtureContents ( 'fixture1.js' )
287
+ const expected = getFixtureContents ( 'outure1.js' )
288
+ expect ( error ) . toMatchObject ( {
289
+ name : expect . stringMatching ( / A s s e r t i o n E r r o r / ) ,
290
+ message : 'Output is incorrect.' ,
291
+ actual,
292
+ expected,
293
+ } )
298
294
} )
299
295
300
296
test ( 'can pass tests in fixtures relative to the filename' , async ( ) => {
@@ -323,17 +319,14 @@ test('can pass tests in fixtures relative to the filename', async () => {
323
319
} )
324
320
325
321
test ( 'can fail tests in fixtures at an absolute path' , async ( ) => {
326
- try {
327
- await runPluginTester (
328
- getOptions ( {
329
- plugin : identifierReversePlugin ,
330
- tests : null ,
331
- fixtures : getFixturePath ( 'failing-fixtures' ) ,
332
- } ) ,
333
- )
334
- } catch ( error ) {
335
- expect ( error . message ) . toMatchSnapshot ( )
336
- }
322
+ const error = await runPluginTester (
323
+ getOptions ( {
324
+ plugin : identifierReversePlugin ,
325
+ tests : null ,
326
+ fixtures : getFixturePath ( 'failing-fixtures' ) ,
327
+ } ) ,
328
+ ) . catch ( e => e )
329
+ expect ( error . message ) . toMatchSnapshot ( )
337
330
} )
338
331
339
332
test ( 'creates output file for new tests' , async ( ) => {
@@ -347,19 +340,10 @@ test('creates output file for new tests', async () => {
347
340
348
341
const calls = writeFileSyncSpy . mock . calls [ 0 ]
349
342
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
- }
343
+ expect ( calls ) . toEqual ( [
344
+ expect . stringMatching ( outputMatch ) ,
345
+ 'export default <div></div>;' ,
346
+ ] )
363
347
} )
364
348
365
349
test ( 'uses the fixture filename in babelOptions' , async ( ) => {
0 commit comments