Skip to content

Commit 6ef571f

Browse files
authored
Merge pull request #133 from Omikorin/fix/regression
fix: regression from 2.8.1
2 parents 6c4ad03 + 9f9f5d5 commit 6ef571f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/index.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ function containsSolidField(fields: Record<string, any>) {
279279
return false;
280280
}
281281

282-
function getJestDomExport(test: { setupFiles: string[] }) {
283-
return (test.setupFiles || []).some((path) => /jest-dom/.test(path))
282+
function getJestDomExport(setupFiles: string[]) {
283+
return (setupFiles || []).some((path) => /jest-dom/.test(path))
284284
? undefined
285285
: ['@testing-library/jest-dom/vitest', '@testing-library/jest-dom/extend-expect'].find(
286286
(path) => {
@@ -328,13 +328,19 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
328328

329329
const test = (userConfig as any).test || {};
330330

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+
331335
if (userConfig.mode === 'test') {
332336
if (!test.environment && !options.ssr) {
333337
test.environment = 'jsdom';
334338
}
335-
const jestDomImport = getJestDomExport(test);
339+
340+
const jestDomImport = getJestDomExport(userSetupFiles);
341+
336342
if (jestDomImport) {
337-
test.setupFiles = [...(test.setupFiles || []), require.resolve(jestDomImport)];
343+
test.setupFiles = [...userSetupFiles, require.resolve(jestDomImport)];
338344
}
339345
}
340346

0 commit comments

Comments
 (0)