@@ -1041,76 +1041,83 @@ describe("blockVitest", () => {
1041
1041
} ) ;
1042
1042
1043
1043
describe ( "intake" , ( ) => {
1044
- it ( "returns undefined when vitest.config.ts does not exist" , ( ) => {
1044
+ it ( "returns nothing when vitest.config.ts does not exist" , ( ) => {
1045
1045
const actual = testIntake ( blockVitest , {
1046
1046
files : {
1047
1047
src : { } ,
1048
1048
} ,
1049
+ options : optionsBase ,
1049
1050
} ) ;
1050
1051
1051
- expect ( actual ) . toEqual ( undefined ) ;
1052
+ expect ( actual ) . toEqual ( { } ) ;
1052
1053
} ) ;
1053
1054
1054
- it ( "returns undefined when vitest.config.ts does not contain the expected defineConfig" , ( ) => {
1055
+ it ( "returns nothing when vitest.config.ts does not contain the expected defineConfig" , ( ) => {
1055
1056
const actual = testIntake ( blockVitest , {
1056
1057
files : {
1057
1058
"vitest.config.ts" : [ `invalid` ] ,
1058
1059
} ,
1060
+ options : optionsBase ,
1059
1061
} ) ;
1060
1062
1061
- expect ( actual ) . toEqual ( undefined ) ;
1063
+ expect ( actual ) . toEqual ( { } ) ;
1062
1064
} ) ;
1063
1065
1064
- it ( "returns undefined when vitest.config.ts passes a non-object to defineConfig" , ( ) => {
1066
+ it ( "returns nothing when vitest.config.ts passes a non-object to defineConfig" , ( ) => {
1065
1067
const actual = testIntake ( blockVitest , {
1066
1068
files : {
1067
1069
"vitest.config.ts" : [ `defineConfig("invalid")` ] ,
1068
1070
} ,
1071
+ options : optionsBase ,
1069
1072
} ) ;
1070
1073
1071
- expect ( actual ) . toEqual ( undefined ) ;
1074
+ expect ( actual ) . toEqual ( { } ) ;
1072
1075
} ) ;
1073
1076
1074
- it ( "returns undefined when vitest.config.ts does not pass a test to defineConfig" , ( ) => {
1077
+ it ( "returns nothing when vitest.config.ts does not pass a test to defineConfig" , ( ) => {
1075
1078
const actual = testIntake ( blockVitest , {
1076
1079
files : {
1077
1080
"vitest.config.ts" : [ `defineConfig({ other: true })` ] ,
1078
1081
} ,
1082
+ options : optionsBase ,
1079
1083
} ) ;
1080
1084
1081
- expect ( actual ) . toEqual ( undefined ) ;
1085
+ expect ( actual ) . toEqual ( { } ) ;
1082
1086
} ) ;
1083
1087
1084
- it ( "returns undefined when vitest.config.ts passes unknown test data to defineConfig" , ( ) => {
1088
+ it ( "returns nothing when vitest.config.ts passes unknown test data to defineConfig" , ( ) => {
1085
1089
const actual = testIntake ( blockVitest , {
1086
1090
files : {
1087
1091
"vitest.config.ts" : [ `defineConfig({ test: true })` ] ,
1088
1092
} ,
1093
+ options : optionsBase ,
1089
1094
} ) ;
1090
1095
1091
- expect ( actual ) . toEqual ( undefined ) ;
1096
+ expect ( actual ) . toEqual ( { } ) ;
1092
1097
} ) ;
1093
1098
1094
- it ( "returns undefined when vitest.config.ts passes invalid test syntax to defineConfig" , ( ) => {
1099
+ it ( "returns nothing when vitest.config.ts passes invalid test syntax to defineConfig" , ( ) => {
1095
1100
const actual = testIntake ( blockVitest , {
1096
1101
files : {
1097
1102
"vitest.config.ts" : [ `defineConfig({ test: { ! } })` ] ,
1098
1103
} ,
1104
+ options : optionsBase ,
1099
1105
} ) ;
1100
1106
1101
- expect ( actual ) . toEqual ( undefined ) ;
1107
+ expect ( actual ) . toEqual ( { } ) ;
1102
1108
} ) ;
1103
1109
1104
- it ( "returns undefined when vitest.config.ts passes invalid test data to defineConfig" , ( ) => {
1110
+ it ( "returns nothing when vitest.config.ts passes invalid test data to defineConfig" , ( ) => {
1105
1111
const actual = testIntake ( blockVitest , {
1106
1112
files : {
1107
1113
"vitest.config.ts" : [
1108
1114
`defineConfig({ test: { coverage: 'invalid' } })` ,
1109
1115
] ,
1110
1116
} ,
1117
+ options : optionsBase ,
1111
1118
} ) ;
1112
1119
1113
- expect ( actual ) . toEqual ( undefined ) ;
1120
+ expect ( actual ) . toEqual ( { } ) ;
1114
1121
} ) ;
1115
1122
1116
1123
it ( "returns coverage and exclude when they exist in vitest.config.ts" , ( ) => {
@@ -1135,6 +1142,7 @@ export default defineConfig({
1135
1142
` ,
1136
1143
] ,
1137
1144
} ,
1145
+ options : optionsBase ,
1138
1146
} ) ;
1139
1147
1140
1148
expect ( actual ) . toEqual ( {
@@ -1145,5 +1153,45 @@ export default defineConfig({
1145
1153
exclude : [ "lib" , "node_modules" ] ,
1146
1154
} ) ;
1147
1155
} ) ;
1156
+
1157
+ it ( "returns environment when it exists in vitest.config.ts" , ( ) => {
1158
+ const actual = testIntake ( blockVitest , {
1159
+ files : {
1160
+ "vitest.config.ts" : [
1161
+ `import { defineConfig } from "vitest/config";
1162
+
1163
+ export default defineConfig({
1164
+ test: {
1165
+ environment: "happy-dom",
1166
+ },
1167
+ });
1168
+ ` ,
1169
+ ] ,
1170
+ } ,
1171
+ options : optionsBase ,
1172
+ } ) ;
1173
+
1174
+ expect ( actual ) . toEqual ( {
1175
+ environment : "happy-dom" ,
1176
+ } ) ;
1177
+ } ) ;
1178
+
1179
+ it ( "returns flags when it exists in package.json" , ( ) => {
1180
+ const actual = testIntake ( blockVitest , {
1181
+ files : { } ,
1182
+ options : {
1183
+ ...optionsBase ,
1184
+ packageData : {
1185
+ scripts : {
1186
+ test : "vitest --typecheck" ,
1187
+ } ,
1188
+ } ,
1189
+ } ,
1190
+ } ) ;
1191
+
1192
+ expect ( actual ) . toEqual ( {
1193
+ flags : [ "--typecheck" ] ,
1194
+ } ) ;
1195
+ } ) ;
1148
1196
} ) ;
1149
1197
} ) ;
0 commit comments