material-svelte / vite-web-test-runner-plugin

MIT License
39 stars 13 forks source link

Add a testing mode when running vite server #19

Closed Manish3323 closed 2 years ago

Manish3323 commented 2 years ago

Adding this mode will start server in the specified (TESTING) mode, eventually users using this plugin will be able to define vite config based on this mode..

This will allow people to configure vite based on TESTING mode.

export default defineConfig(async ({ mode }) => {
  console.log('****************' + mode + '*********')
  const testDeps =
    mode === 'TESTING'
      ? [
          '@testing-library/react',
          '@testing-library/user-event',
          'chai',
          'ts-mockito',
          '@testing-library/react-hooks/dom'
        ]
      : []
  return {
    server: {
      port: 9000
    },
    base: `./`,
    optimizeDeps: {
      include: testDeps
    },
    build: {
      outDir: AppConfig.applicationName,
      sourcemap: 'inline',
      rollupOptions: {
        input: ['./index.html']
      }
    },
    plugins: [reactRefresh()]
  }
})
Manish3323 commented 2 years ago

Also, this will explain in detail.

Manish3323 commented 2 years ago

closing this as WEB_TEST_RUNNER sets NODE_ENV = test which can be used also..