mammadataei / cypress-vite

Run Cypress specs using Vite
MIT License
85 stars 10 forks source link

Can't run tests in SvelteKit app #100

Open L-Mario564 opened 1 month ago

L-Mario564 commented 1 month ago

It seems there's a conflict between the config file and the SvelteKit config. Here's the logged error:

The following Vite config options will be overridden by SvelteKit:
  - build.outDir

I can't run any tests because of this. Here's are my configs:

// cypress.config.ts
import vitePreprocessor from 'cypress-vite';
import { defineConfig } from 'cypress';

const setupNodeEvents: Parameters<typeof defineConfig>[0]['setupNodeEvents'] = (on) => {
  const vite = vitePreprocessor(`${process.cwd()}/vite.config.ts`);
  on('file:preprocessor', vite);
};

export default defineConfig({
  e2e: {
    setupNodeEvents,
    baseUrl: 'http://localhost:5173',
    // More config options...
  }
});

// vite.config.ts
import 'sharp';
import { purgeCss } from 'vite-plugin-tailwind-purgecss';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [sveltekit(), purgeCss()],
  envPrefix: 'PUBLIC_'
});

// svelte.config.js
import adapter from '@sveltejs/adapter-vercel';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
const config = {
  preprocess: vitePreprocess(),
  kit: {
    adapter: adapter(),
    alias: {
      // ...
    }
  }
};

export default config;