Skip to content

Instantly share code, notes, and snippets.

@lejonmanen
Created May 13, 2024 19:57
Show Gist options
  • Save lejonmanen/c4e3736aabe31dedeaf40b134ff61de0 to your computer and use it in GitHub Desktop.
Save lejonmanen/c4e3736aabe31dedeaf40b134ff61de0 to your computer and use it in GitHub Desktop.
Example Cypress config for Vite+React
// This example produced 2024-05-13
// vite.config.js
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
server: {
port: 7123, // pick any port number
host: true // this is the critical setting
},
baseUrl: '/' // make relative URLs work better with GitHub Pages
})
// --------------------
// cypress.config.js
import { defineConfig } from "cypress";
// Cypress has separate settings for component testing and E2E testing
// component testing works out of the box, but not E2E
export default defineConfig({
component: {
devServer: {
framework: "react",
bundler: "vite",
},
},
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
baseUrl: 'http://localhost:7123/' // must be same port as in vite.config.js
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment