-
Notifications
You must be signed in to change notification settings - Fork 1k
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
CT Public API docs #5069
CT Public API docs #5069
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple wording suggestions and questions, but overall this is awesome content!
One total nitpick - the screenshots have 12.6.0 but this feature is marked as 12.7+
We should probably update the supported frameworks to also mention community libraries with a link to this guide and link to a list of community libs. Where would be a good place to list the community libraries in the docs? My initial thoughts is we can remove the older CT libs from the component testing section in plugins and list them there. |
|
||
The second part of defining a Framework Definition is the Mount Adapter. This is the function that renders the component in your tests using `cy.mount()`. | ||
|
||
By default, Cypress will look for this as a `mount` function that is a **named export** from the package. This should be written in a `index.mjs` file. This example is for a [Solid.js](https://www.solidjs.com/) mount adapter: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be showing the examples in TypeScript and highly recommending that TS is used in their own libraries.
We might even think about putting together a starter template that someone could just clone and it would have building and bundling baked in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, I see reading further down there is a template, but I think that should be updated to TypeScript with the build steps built in (like above). This will help ensure that the Typings get created and (🌶) all libs should be built in TS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be good to mention the template earlier in the guide as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not do this initially since I thought it added quite a bit of complexity. The build step is a little messy. Cypress (the server component) will always require the CJS entry - in this case, definition.cjs
. Both our bundlers (webpack and vite) want an ES module. We would need two separate build steps - one for the Node.js entry and one for the ESM entry.
I updated the template to have TypeScript by default. It has two tsconfig.json
- one for the server entry (definition) and one for the mount entry (esm). Take a look and let me know what you think @elylucas: https://github.com/cypress-io/cypress-ct-definition-template
I also updated my own example to use this template: https://github.com/lmiller1990/cypress-ct-solid-js
Co-authored-by: Ely Lucas <ely@meta-tek.net> Co-authored-by: Mike Plummer <mike-plummer@users.noreply.github.com>
|
||
## Testing | ||
|
||
If you develop the Framework Definition file using TypeScript, for example by using [our official template](https://github.com/cypress-io/cypress-ct-definition-template), as long as you don't have any compile time errors, everything should work as expected. If you do run into unexpected behavior, please [file an issue](https://github.com/cypress-io/cypress/issues). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth noting we've got better warnings for definitions coming VERY soon (next sprint) cypress-io/cypress#25838 but they are not supported right now. The issue requires the docs to be updated when they are added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elylucas @mike-plummer thanks for the reviews, I have done my best to address all comments. I also updated the official template to include TypeScript and my own example to use it.
Will merge once 12.7 goes out with https://github.com/cypress-io/cypress/pull/25780/files in it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
// Wait until next microtick to ensure any async render logic has executed | ||
return cy.wait(0, { log: false }).then(() => { | ||
if (options.log) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work unless we check the value of options.log
. We're assuming that it's true here but that's not the case unless it is explicitly set. Should we change this to
if (options.log) { | |
if (options.log !== false) { |
@lmiller1990 do you think we should mention dev server support at all? Maybe suggest a way to give users a custom dev server function to drop into their config until we build support for that? Is that something that we want to encourage? Not sure 🤔 |
|
I think this is a good idea. I've been trying to throw together one and the point I got stuck on was getting the dev server up and running. One project was vite and the other is a custom dev server and couldn't really get either working. Would be good to know (and update the custom dev server section under framework configuration) how to set one up from scratch. |
closes cypress-io/cypress#25800
Docs for the new Framework Definitions feature. Epic: cypress-io/cypress#25637 (linked to all relevant issues).