Skip to content

Vitest config is dropped when test.server.deps.external already lists solid-js #454

Open

Description

@RaphaelFakhri

On the 2.x line (main), vite-plugin-solid returns its test config only when it also sets test.server. If the user config already has solid-js in test.server.deps.external, the plugin does not set test.server, so it also drops test.environment = 'jsdom' and the @testing-library/jest-dom setup file.

Reproduction

// vitest.config.ts
import { defineConfig } from 'vitest/config';
import solid from 'vite-plugin-solid';

export default defineConfig({
  plugins: [solid()],
  test: { server: { deps: { external: [/solid-js/] } } },
});

The resolved Vitest config has no environment and no jest-dom setup file, so tests run in the default node environment, where DOM APIs such as document are not defined. Without the server.deps.external entry, the plugin sets both.

Expected behavior

The plugin sets the jsdom environment and the jest-dom setup file whether or not solid-js is already external. The next branch already does this (Object.keys(test).length ? { test } : {}).

Cause

Introduced in #183: ...(test.server ? { test } : {}) in src/index.ts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions