66 *
77 */
88
9- 'use strict' ;
10-
11- import { makeProjectConfig } from '../../../../TestUtils' ;
9+ import { makeGlobalConfig , makeProjectConfig } from '../../../../TestUtils' ;
1210
1311jest
1412 . mock ( 'fs' , ( ) =>
@@ -214,9 +212,10 @@ describe('ScriptTransformer', () => {
214212
215213 it ( 'transforms a file properly' , ( ) => {
216214 const scriptTransformer = new ScriptTransformer ( config ) ;
217- const response = scriptTransformer . transform ( '/fruits/banana.js' , {
218- collectCoverage : true ,
219- } ) . script ;
215+ const response = scriptTransformer . transform (
216+ '/fruits/banana.js' ,
217+ makeGlobalConfig ( { collectCoverage : true } ) ,
218+ ) . script ;
220219
221220 expect ( response instanceof vm . Script ) . toBe ( true ) ;
222221 expect ( vm . Script . mock . calls [ 0 ] [ 0 ] ) . toMatchSnapshot ( ) ;
@@ -226,24 +225,32 @@ describe('ScriptTransformer', () => {
226225 expect ( fs . readFileSync ) . toBeCalledWith ( '/fruits/banana.js' , 'utf8' ) ;
227226
228227 // in-memory cache
229- const response2 = scriptTransformer . transform ( '/fruits/banana.js' , {
230- collectCoverage : true ,
231- } ) . script ;
228+ const response2 = scriptTransformer . transform (
229+ '/fruits/banana.js' ,
230+ makeGlobalConfig ( { collectCoverage : true } ) ,
231+ ) . script ;
232232 expect ( response2 ) . toBe ( response ) ;
233233
234- scriptTransformer . transform ( '/fruits/kiwi.js' , {
235- collectCoverage : true ,
236- } ) ;
234+ scriptTransformer . transform (
235+ '/fruits/kiwi.js' ,
236+ makeGlobalConfig ( { collectCoverage : true } ) ,
237+ ) ;
237238 const snapshot = vm . Script . mock . calls [ 1 ] [ 0 ] ;
238239 expect ( snapshot ) . toMatchSnapshot ( ) ;
239240
240- scriptTransformer . transform ( '/fruits/kiwi.js' , { collectCoverage : true } ) ;
241+ scriptTransformer . transform (
242+ '/fruits/kiwi.js' ,
243+ makeGlobalConfig ( { collectCoverage : true } ) ,
244+ ) ;
241245
242246 expect ( vm . Script . mock . calls [ 0 ] [ 0 ] ) . not . toEqual ( snapshot ) ;
243247 expect ( vm . Script . mock . calls [ 0 ] [ 0 ] ) . not . toMatch ( / i n s t r u m e n t e d k i w i / ) ;
244248
245249 // If we disable coverage, we get a different result.
246- scriptTransformer . transform ( '/fruits/kiwi.js' , { collectCoverage : false } ) ;
250+ scriptTransformer . transform (
251+ '/fruits/kiwi.js' ,
252+ makeGlobalConfig ( { collectCoverage : false } ) ,
253+ ) ;
247254 expect ( vm . Script . mock . calls [ 1 ] [ 0 ] ) . toEqual ( snapshot ) ;
248255
249256 scriptTransformer . transform ( '/fruits/banana.js' , {
@@ -401,9 +408,12 @@ describe('ScriptTransformer', () => {
401408 map,
402409 } ) ;
403410
404- const result = scriptTransformer . transform ( '/fruits/banana.js' , {
405- collectCoverage : true ,
406- } ) ;
411+ const result = scriptTransformer . transform (
412+ '/fruits/banana.js' ,
413+ makeGlobalConfig ( {
414+ collectCoverage : true ,
415+ } ) ,
416+ ) ;
407417 expect ( result . sourceMapPath ) . toEqual ( expect . any ( String ) ) ;
408418 const mapStr = JSON . stringify ( map ) ;
409419 expect ( writeFileAtomic . sync ) . toBeCalledTimes ( 2 ) ;
@@ -431,9 +441,12 @@ describe('ScriptTransformer', () => {
431441
432442 require ( 'preprocessor-with-sourcemaps' ) . process . mockReturnValue ( content ) ;
433443
434- const result = scriptTransformer . transform ( '/fruits/banana.js' , {
435- collectCoverage : true ,
436- } ) ;
444+ const result = scriptTransformer . transform (
445+ '/fruits/banana.js' ,
446+ makeGlobalConfig ( {
447+ collectCoverage : true ,
448+ } ) ,
449+ ) ;
437450 expect ( result . sourceMapPath ) . toEqual ( expect . any ( String ) ) ;
438451 expect ( writeFileAtomic . sync ) . toBeCalledTimes ( 2 ) ;
439452 expect ( writeFileAtomic . sync ) . toBeCalledWith (
@@ -468,9 +481,12 @@ describe('ScriptTransformer', () => {
468481
469482 require ( 'preprocessor-with-sourcemaps' ) . process . mockReturnValue ( content ) ;
470483
471- const result = scriptTransformer . transform ( '/fruits/banana.js' , {
472- collectCoverage : true ,
473- } ) ;
484+ const result = scriptTransformer . transform (
485+ '/fruits/banana.js' ,
486+ makeGlobalConfig ( {
487+ collectCoverage : true ,
488+ } ) ,
489+ ) ;
474490 expect ( result . sourceMapPath ) . toBeNull ( ) ;
475491 expect ( writeFileAtomic . sync ) . toBeCalledTimes ( 1 ) ;
476492
@@ -496,9 +512,12 @@ describe('ScriptTransformer', () => {
496512 map,
497513 } ) ;
498514
499- const result = scriptTransformer . transform ( '/fruits/banana.js' , {
500- collectCoverage : true ,
501- } ) ;
515+ const result = scriptTransformer . transform (
516+ '/fruits/banana.js' ,
517+ makeGlobalConfig ( {
518+ collectCoverage : true ,
519+ } ) ,
520+ ) ;
502521 expect ( result . sourceMapPath ) . toEqual ( expect . any ( String ) ) ;
503522 expect ( writeFileAtomic . sync ) . toBeCalledTimes ( 2 ) ;
504523 expect ( writeFileAtomic . sync ) . toBeCalledWith (
@@ -522,9 +541,12 @@ describe('ScriptTransformer', () => {
522541 map : null ,
523542 } ) ;
524543
525- const result = scriptTransformer . transform ( '/fruits/banana.js' , {
526- collectCoverage : true ,
527- } ) ;
544+ const result = scriptTransformer . transform (
545+ '/fruits/banana.js' ,
546+ makeGlobalConfig ( {
547+ collectCoverage : true ,
548+ } ) ,
549+ ) ;
528550 expect ( result . sourceMapPath ) . toBeFalsy ( ) ;
529551 expect ( writeFileAtomic . sync ) . toHaveBeenCalledTimes ( 1 ) ;
530552 } ) ;
@@ -533,9 +555,12 @@ describe('ScriptTransformer', () => {
533555 config = { ...config , transform : [ [ '^.+\\.js$' , 'test_preprocessor' ] ] } ;
534556 const scriptTransformer = new ScriptTransformer ( config ) ;
535557
536- scriptTransformer . transform ( '/fruits/banana.js' , {
537- collectCoverage : true ,
538- } ) ;
558+ scriptTransformer . transform (
559+ '/fruits/banana.js' ,
560+ makeGlobalConfig ( {
561+ collectCoverage : true ,
562+ } ) ,
563+ ) ;
539564
540565 const { getCacheKey} = require ( 'test_preprocessor' ) ;
541566 expect ( getCacheKey . mock . calls [ 0 ] [ 3 ] ) . toMatchSnapshot ( ) ;
0 commit comments