-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Using Parcel as a dev server #17798
Comments
Cross-posting my own response.
|
I would be willing to help test this since I want to learn cypress and currently use Parcel. |
seconding this request, much needed |
+1 |
2 similar comments
+1 |
+1 |
+1, the docs are lacking in this area |
This is very much needed, Parcel is common. Is there any workaround besides introducing webpack? |
Agreed docs are lacking: https://cypress-documentation-8cl0tm1rj-cypress-io.vercel.app/guides/component-testing/component-framework-configuration#Custom-Dev-Server This is almost certainly possible right now, let's work on it. First step is look at ^^^^^ docs and try pointing it at your Parcel dev server and see if you can get something rendering in Cypress Component Testing. Once that is working, I can writeup what else is needed - basically we just need to respond with the right events. Vite dev server is probably the most "simple" example of a dev server here. The events are things like this, eg Anyone have Parcel dev experience who'd like to work on this with me? |
I tried a bit: https://github.com/lmiller1990/parcel-cypress-plugin I got stuck on Cypress is asking for Also, any way to customize the HTML Parcel's Dev Server uses? In Vite we can do |
@lmiller1990 i wonder if creating a custom target will make this work ok. How does Cypress interact with the dev server? When it's asking for |
Hmm good question - it's an cypress/npm/vite-dev-server/client/initCypressTests.js Lines 43 to 47 in 1c5a67f
It's a JS blob that imports the correct spec, and some runtime code to execute the test (fairly Cypress specific, but I can handle this - once we figure out how to tell Parcel what to serve for a given URL). |
@lmiller1990 do you think it'd be sufficient to write a small script that handles taking the path sent by Cypress to send the right response back? I don't have a good picture of the entirety of what's needed to make this work, but would a solution like that be sufficient? Parcel already rewrites requests, so it'd just be a matter of writing the proper script to handle the request. |
@daviesgeek I think so - as long as the correct I'm not sure I have time to work on it now, but I can definitely review/look at code if you'd like to take a look at it. |
@lmiller1990 i can see what i can do; how did you get to the point of the above where cypress is actually attempting to load the parcel dev server up? It's been a little bit , but last time I tried, i don't think i got that far |
Been a while for me but all the code I wrote should be in this repo: https://github.com/lmiller1990/parcel-cypress-plugin/ The bulk of the dev server stuff would go in https://github.com/lmiller1990/parcel-cypress-plugin/blob/main/cypress.config.js If you need help navigating the Cypress code base, lmk, but theoretically this should all be do-able from outside - our webpack and vite dev servers are completely separate from the main code base, too.
The code lives in this repo https://github.com/cypress-io/cypress/tree/develop/npm but they are developed and deployed in isolation. If you can get the routing to work and serve the correct spec, I can wire up all the hot reload events and that kind of thing. |
If anyone wants to work on this, good example of how to build a dev server: https://github.com/fochlac/cypress-devserver-esbuild/tree/main |
Hi there. I'm currently setting up a project which will accomplish this. The most tricky part is fiddling around with the |
I finally reached a working setup. Few things:
I'm still researching and evolving the solution |
There was some minor updates to our docs recently: https://docs.cypress.io/guides/component-testing/component-framework-configuration#Custom-Dev-Server
I can take a look if you are really stuck, just share your GH repo. |
I would like to share but the setup is still experimental and currently versioned within a private monorepo at gitlab.com. As said, "it works". Quotes because I still need to figure out how to properly detect and trigger re-runs when specs - or the code they depend upon - change. It's sub-optimal having to refresh manually, ofc 😅 . It would be awesome if you can point me to some places at I expect to extract the relevant source from the private monorepo and publish on a near future, so people looking for a pattern to integrate with parcel can benefit. Thanks for feedback |
Sure, you should have access to export default defineConfig({
component: {
async devServer({ specs, cypressConfig, devServerEvents }: DevServerOptions) {
^^^^^^^^^^^^^^^ here it is, it's an event emitter, emit things
const { port, close } = await startDevServer(
specs,
cypressConfig,
devServerEvents
)
return {
port,
close,
}
},
},
}) You can then do something like this:
this.devServerEvents.emit('dev-server:compile:success') Search for Just ask if you have more questions, I haven't worked on the dev servers in quite some time so I will also need to do a refresher. If you can make your code public, I could take a look. |
It has been over a year since the last comment, so has there been any progress towards moving this into the baseline? We could certainly use the parcel dev server. |
I don't think anyone is working on this. |
Discussed in #16977
Originally posted by mscoobby June 17, 2021
Hello everyone,
We've started using Cypress for testing our React based application and it works great but we are using Parcel to bundle the application and it would be nice if we don't have to introduce webpack to the project. I've looked around and tried different things but could not manage to make Cypress component testing work without webpack. I would appreciate any information on the topic.
The text was updated successfully, but these errors were encountered: