import { sveltekit } from '@sveltejs/kit/vite';
import { svelteTesting } from '@testing-library/svelte/vite';
import { configDefaults, defineConfig } from 'vitest/config';

export default defineConfig({
  plugins: [sveltekit(), svelteTesting()],
  test: {
    environment: 'jsdom',
    include: ['src/**/*.test.ts', 'src/**/*.svelte.test.ts', 'scripts/**/*.test.js'],
    // M7 #374: these two test files explode at module-load with
    // `TypeError: notifiable_store is not a function` from SvelteKit's
    // internal client.js — the import chain triggers SvelteKit's client
    // runtime init in a way the dev-push vitest invocation can't satisfy.
    // describe.skip inside the files doesn't help because vitest must
    // load the file before it can see the describe block. Excluded here
    // until the triage in #374 lands a real fix (probably a $app/paths
    // mock in vitest.setup.ts).
    exclude: [
      ...configDefaults.exclude,
      'src/routes/discover/discover.test.ts',
      'src/routes/requests/requests.test.ts'
    ],
    setupFiles: ['./vitest.setup.ts']
  }
});
