@@ -280,12 +280,13 @@ function containsSolidField(fields: Record<string, any>) {
280
280
}
281
281
282
282
function getJestDomExport ( setupFiles : string [ ] ) {
283
- return ( setupFiles || [ ] ) . some ( ( path ) => / j e s t - d o m / . test ( path ) )
283
+ return setupFiles ? .some ( ( path ) => / j e s t - d o m / . test ( path ) )
284
284
? undefined
285
285
: [ '@testing-library/jest-dom/vitest' , '@testing-library/jest-dom/extend-expect' ] . find (
286
286
( path ) => {
287
287
try {
288
- require ( path ) ;
288
+ require . resolve ( path ) ;
289
+ return true ;
289
290
} catch ( e ) {
290
291
return false ;
291
292
}
@@ -328,19 +329,24 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
328
329
329
330
const test = ( userConfig as any ) . test || { } ;
330
331
331
- // to simplify the processing of the config, we normalize the setupFiles to an array
332
- const userSetupFiles : string [ ] =
333
- typeof test . setupFiles === 'string' ? [ test . setupFiles ] : test . setupFiles || [ ] ;
334
-
335
332
if ( userConfig . mode === 'test' ) {
333
+ // to simplify the processing of the config, we normalize the setupFiles to an array
334
+ const userSetupFiles : string [ ] =
335
+ typeof test . setupFiles === 'string' ? [ test . setupFiles ] : test . setupFiles || [ ] ;
336
+
336
337
if ( ! test . environment && ! options . ssr ) {
337
338
test . environment = 'jsdom' ;
338
339
}
339
340
340
- const jestDomImport = getJestDomExport ( userSetupFiles ) ;
341
+ test . server = test . server || { } ;
342
+ test . server . deps = test . server . deps || { } ;
343
+ if ( ! test . server . deps . inline ?. find ( ( item : string | RegExp ) => / s o l i d - j s / . test ( item . toString ( ) ) ) ) {
344
+ test . server . deps . inline = [ ...( test . server . deps . inline || [ ] ) , / s o l i d - j s / ] ;
345
+ }
341
346
347
+ const jestDomImport = getJestDomExport ( userSetupFiles ) ;
342
348
if ( jestDomImport ) {
343
- test . setupFiles = [ ...userSetupFiles , require . resolve ( jestDomImport ) ] ;
349
+ test . setupFiles = [ ...userSetupFiles , jestDomImport ] ;
344
350
}
345
351
}
346
352
@@ -364,7 +370,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
364
370
exclude : solidPkgsConfig . optimizeDeps . exclude ,
365
371
} ,
366
372
ssr : solidPkgsConfig . ssr ,
367
- ...( test ? { test } : { } ) ,
373
+ ...( test . server ? { test } : { } ) ,
368
374
} ;
369
375
} ,
370
376
0 commit comments