@@ -12,7 +12,7 @@ const ROOT_DIR = path.join(__dirname, '..');
12
12
13
13
function apiCreator ( options ) {
14
14
options = options || { } ;
15
- options . babelConfig = options . babelConfig || 'default' ;
15
+ options . babelConfig = options . babelConfig || { testOptions : { } } ;
16
16
options . projectDir = options . projectDir || ROOT_DIR ;
17
17
options . resolveTestsFrom = options . resolveTestsFrom || options . projectDir ;
18
18
const instance = new Api ( options ) ;
@@ -817,13 +817,14 @@ function generateTests(prefix, apiCreator) {
817
817
} ) ;
818
818
} ) ;
819
819
820
- test ( `${ prefix } Custom Babel Plugin Support ` , t => {
820
+ test ( `${ prefix } babel.testOptions with a custom plugin ` , t => {
821
821
t . plan ( 2 ) ;
822
822
823
823
const api = apiCreator ( {
824
824
babelConfig : {
825
- presets : [ '@ava/stage-4' ] ,
826
- plugins : [ testCapitalizerPlugin ]
825
+ testOptions : {
826
+ plugins : [ testCapitalizerPlugin ]
827
+ }
827
828
} ,
828
829
cacheEnabled : false ,
829
830
projectDir : __dirname
@@ -841,31 +842,10 @@ function generateTests(prefix, apiCreator) {
841
842
} , t . threw ) ;
842
843
} ) ;
843
844
844
- test ( `${ prefix } Default babel config uses .babelrc` , t => {
845
- t . plan ( 3 ) ;
846
-
847
- const api = apiCreator ( {
848
- projectDir : path . join ( __dirname , 'fixture/babelrc' )
849
- } ) ;
850
-
851
- api . on ( 'test-run' , runStatus => {
852
- runStatus . on ( 'test' , data => {
853
- t . ok ( ( data . title === 'foo' ) || ( data . title === 'repeated test: foo' ) ) ;
854
- } ) ;
855
- } ) ;
856
-
857
- return api . run ( )
858
- . then ( result => {
859
- t . is ( result . passCount , 2 ) ;
860
- } ) ;
861
- } ) ;
862
-
863
- test ( `${ prefix } babelConfig:"inherit" uses .babelrc` , t => {
845
+ test ( `${ prefix } babel.testOptions.babelrc effectively defaults to true` , t => {
864
846
t . plan ( 3 ) ;
865
847
866
848
const api = apiCreator ( {
867
- babelConfig : 'inherit' ,
868
- cacheEnabled : false ,
869
849
projectDir : path . join ( __dirname , 'fixture/babelrc' )
870
850
} ) ;
871
851
@@ -881,11 +861,13 @@ function generateTests(prefix, apiCreator) {
881
861
} ) ;
882
862
} ) ;
883
863
884
- test ( `${ prefix } babelConfig:{ babelrc:true} uses .babelrc ` , t => {
864
+ test ( `${ prefix } babel.testOptions. babelrc can explicitly be true ` , t => {
885
865
t . plan ( 3 ) ;
886
866
887
867
const api = apiCreator ( {
888
- babelConfig : { babelrc : true } ,
868
+ babelConfig : {
869
+ testOptions : { babelrc : true }
870
+ } ,
889
871
cacheEnabled : false ,
890
872
projectDir : path . join ( __dirname , 'fixture/babelrc' )
891
873
} ) ;
@@ -902,11 +884,13 @@ function generateTests(prefix, apiCreator) {
902
884
} ) ;
903
885
} ) ;
904
886
905
- test ( `${ prefix } babelConfig:{ babelrc:false} does not use .babelrc ` , t => {
887
+ test ( `${ prefix } babel.testOptions. babelrc can explicitly be false ` , t => {
906
888
t . plan ( 2 ) ;
907
889
908
890
const api = apiCreator ( {
909
- babelConfig : { babelrc : false } ,
891
+ babelConfig : {
892
+ testOptions : { babelrc : false }
893
+ } ,
910
894
cacheEnabled : false ,
911
895
projectDir : path . join ( __dirname , 'fixture/babelrc' )
912
896
} ) ;
@@ -923,13 +907,15 @@ function generateTests(prefix, apiCreator) {
923
907
} ) ;
924
908
} ) ;
925
909
926
- test ( `${ prefix } babelConfig:{babelrc:true, plugins:[...]} merges plugins with .babelrc` , t => {
910
+ test ( `${ prefix } babelConfig.testOptions merges plugins with .babelrc` , t => {
927
911
t . plan ( 3 ) ;
928
912
929
913
const api = apiCreator ( {
930
914
babelConfig : {
931
- plugins : [ testCapitalizerPlugin ] ,
932
- babelrc : true
915
+ testOptions : {
916
+ babelrc : true ,
917
+ plugins : [ testCapitalizerPlugin ]
918
+ }
933
919
} ,
934
920
cacheEnabled : false ,
935
921
projectDir : path . join ( __dirname , 'fixture/babelrc' )
@@ -947,13 +933,15 @@ function generateTests(prefix, apiCreator) {
947
933
} ) ;
948
934
} ) ;
949
935
950
- test ( `${ prefix } babelConfig:{ extends:path, plugins:[...]} merges plugins with .babelrc` , t => {
936
+ test ( `${ prefix } babelConfig.testOptions with extends still merges plugins with .babelrc` , t => {
951
937
t . plan ( 3 ) ;
952
938
953
939
const api = apiCreator ( {
954
940
babelConfig : {
955
- plugins : [ testCapitalizerPlugin ] ,
956
- extends : path . join ( __dirname , 'fixture/babelrc/.alt-babelrc' )
941
+ testOptions : {
942
+ plugins : [ testCapitalizerPlugin ] ,
943
+ extends : path . join ( __dirname , 'fixture/babelrc/.alt-babelrc' )
944
+ }
957
945
} ,
958
946
cacheEnabled : false ,
959
947
projectDir : path . join ( __dirname , 'fixture/babelrc' )
0 commit comments