@@ -4,7 +4,7 @@ import assert from 'assert'
44import path from 'path'
55import fs from 'fs'
66import pathExists from 'path-exists'
7- import merge from 'lodash.merge '
7+ import mergeWith from 'lodash.mergewith '
88import invariant from 'invariant'
99import stripIndent from 'strip-indent'
1010import { oneLine } from 'common-tags'
@@ -21,6 +21,13 @@ const fullDefaultConfig = {
2121 } ,
2222}
2323
24+ function mergeCustomizer ( objValue , srcValue ) {
25+ if ( Array . isArray ( objValue ) ) {
26+ return objValue . concat ( srcValue )
27+ }
28+ return undefined
29+ }
30+
2431function pluginTester ( {
2532 /* istanbul ignore next (TODO: write a test for this) */
2633 babel = require ( '@babel/core' ) ,
@@ -52,7 +59,7 @@ function pluginTester({
5259 if ( ! testAsArray . length ) {
5360 return
5461 }
55- const testerConfig = merge ( { } , fullDefaultConfig , rest )
62+ const testerConfig = mergeWith ( { } , fullDefaultConfig , rest , mergeCustomizer )
5663
5764 describe ( describeBlockTitle , ( ) => {
5865 testAsArray . forEach ( testConfig => {
@@ -72,7 +79,7 @@ function pluginTester({
7279 setup = noop ,
7380 teardown,
7481 formatResult = r => r ,
75- } = merge ( { } , testerConfig , toTestConfig ( testConfig ) )
82+ } = mergeWith ( { } , testerConfig , toTestConfig ( testConfig ) , mergeCustomizer )
7683 assert (
7784 ( ! skip && ! only ) || skip !== only ,
7885 'Cannot enable both skip and only on a test' ,
@@ -191,7 +198,7 @@ function pluginTester({
191198 output = getCode ( filename , testConfig . outputFixture ) || undefined ,
192199 pluginOptions : testOptions = pluginOptions ,
193200 } = testConfig
194- return merge (
201+ return mergeWith (
195202 {
196203 babelOptions : { filename : getPath ( filename , fixture ) } ,
197204 } ,
@@ -202,6 +209,7 @@ function pluginTester({
202209 code : stripIndent ( code ) . trim ( ) ,
203210 ...( output ? { output : stripIndent ( output ) . trim ( ) } : { } ) ,
204211 } ,
212+ mergeCustomizer ,
205213 )
206214 }
207215}
@@ -257,7 +265,7 @@ const createFixtureTests = (fixturesDir, options) => {
257265
258266 const babelRcPath = path . join ( fixtureDir , '.babelrc' )
259267
260- const { babelOptions} = merge (
268+ const { babelOptions} = mergeWith (
261269 { } ,
262270 fullDefaultConfig ,
263271 {
@@ -278,6 +286,7 @@ const createFixtureTests = (fixturesDir, options) => {
278286 } ,
279287 } ,
280288 rest ,
289+ mergeCustomizer ,
281290 )
282291 const actual = formatResult (
283292 babel . transformFileSync ( codePath , babelOptions ) . code . trim ( ) ,
0 commit comments