-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module API to start the SvelteKit (vite) dev server #2921
Comments
To get a reference to the devserver and config, you can ask users to add a plugin to export function vitePluginCypressHelper() {
let server: ViteDevServer;
let config: ConfigResolved;
const plugin = {
name: 'vite-plugin-cypress-helper',
apply: 'serve', // plugin will be skipped on vite build
configResolved(_config) {
config = _config;
}
configureServer(_server) {
server = _server;
// server has useful api too, like access to the pluginContainer, moduleGraph
}
buildStart() {
// called after initialization, do stuff with server and config here
}
}
} vite plugins can modify config (should be stable in configResolved) and customize module resolving too (eg https://github.com/aleclarson/vite-tsconfig-paths) so i'd recommend to use vites own api on the devserver instance over just parsing the config unless you are sure that the information you get from the config (path aliases i assume?) is working as intended in vite at runtime |
@dominikg I can't believe it's been 4 days already! I'll give this a go tonight. |
@JessicaSachs Any updates on this? |
Did I seriously already create this issue? Even if my short term memory is bad, at least I'm consistent. |
Closing this as it appears to be a dupe of #4329 (or vice versa, but the discussion is happening over there) |
Describe the problem
Hello! I'm adding Svelte (and SvelteKit) support for Cypress Component Testing.
For component testing in Cypress, we use a dev-server based architecture to bundle and serve each of your components (and their tests!) in isolation. Kind of like if each of your Spec files got its own HTML page.
Whenever we add support for a new app framework, we need the ability to start the user's local dev server from a node process and receive a handle to the server that was started.
Since SvelteKit is built on top of Vite, I can just use our existing
@cypress/vite-dev-server
, except that because SvelteKit'ssvelte.config.js
config file augments the Vite Config with its own internal options (similar to how CRA, NextJS and Vue CLI wrap Webpack) I need to be able to get at the resolved configuration.Describe the proposed solution
I would like one of two things. Either:
Alternatives considered
No response
Importance
Cannot use SvelteKit without this.
Additional Information
I can likely work around this for simple use cases, but withoutUnless SvelteKit exposes the resolved options or there's a module API to start the server, we'll be unable to test components that reference the$app
module.The text was updated successfully, but these errors were encountered: