-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Feature/add cypress #3062
Feature/add cypress #3062
Conversation
Size Comparison
✅ None of the examples has changed their size significantly. |
My 2 cents: that's a lot of JS code that I'm not really comfortable with putting in examples. It would also need to run in CI. None of it is Yew specific and I think we're better served by mentioning it in our documentation and redirecting users to cypress' docs |
I actually like the idea. Weighing between not having end-to-end tests and having them based on javascript, I prefer the latter - given that they do tend to break from time to time partly because we're using the nightly compiler for the deployment. But: Do you have a blogpost or short explanation on how to use this? I'm not sure how best to run the tests locally, the README you're refering to doesn't seem to be part of the PR. Where I agree with hamza is that this e2e setup should perhaps not be a part of a specific example, but form a test-suite we run as part of CI. |
I forgot to push the README so I pushed it, sorry. I think with the instructions I wrote in the README you can start cypress e2e test following it I agree with both of you, doing manual e2e testing only for certain EXAMPLE is a bad idea and should be incorporated into CI So I have a question, is there a standard project that should be e2e tested? Or should we create one? |
There is no "one project" currently, the examples are built and then pasted together for deployment, see |
If we're using JS for end-to-end testing, I would prefer it to based on Playwright. Cypress is great but for this particular use-case, it seems too bulky (it has so much functionality like API routes mocking, fixtures and such) that we don't need, since the examples don't really rely on user input. It also supports screenshot testing out of the box, which Cypress does not. We can have I appreciate your effort for making this PR and getting a discussion started. It seems most of the code in the PR is from the template (I don't want your effort to be for nothing). It would be great if we moved this discussion to an issue (there tends to be more activity). See #196, or if you want, you can create a new issue |
I am indifferent between Cypress and Playwright if the notion is to adopt a JavaScript-based Testing Library for E2E tests. Cypress provides everything out of the box so we do not need to worry anything about setting up the toolchain. I am usually against framework, but in this case this works in our favour as we do not want to devote too much time at setting up and maintaining JavaScript testing framework (jest?), bundler, etc for JavaScript testing. However, I found Playwright to have be better at writing tests that works reliably and Cypress are more likely to be flaky and tend to break things upon major version upgrade. Regardless of whether Cypress or Playwright are selected, I would like to see something like Yarn Workspace to be used so we do not end up with many separate and duplicated |
The thing about Playwright is that we can the test files where we want to. There can be only one package.json in the examples directory so duplication of node_modules can be avoided |
examples/todomvc/package.json
Outdated
"cypress:run": "cypress run --browser chrome" | ||
}, | ||
"author": "", | ||
"license": "ISC", |
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.
"license": "ISC", | |
"license": "(MIT OR Apache-2.0)", |
Yew is licensed in MIT OR Apache-2.0 at the users choice, I believe tests should also follow this license.
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.
Thanks for the review, I fixed it to MIT OR Apache-2.0
examples/todomvc/cypress.config.ts
Outdated
export default defineConfig({ | ||
e2e: { | ||
baseUrl: "http://localhost:8080", | ||
"defaultCommandTimeout": 30000 |
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 would prefer the default command timeout to remain 4_000
as doing so may significantly extend test runtime if many tests start to fail (which is not uncommon if we are trying to update Yew itself.)
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 changed it to 4_000
You can also do it with by specifying I just felt it might be better to give each example their own
I forgot to mention, |
I greatly appreciate the productive responses from all of you! The reason Cypress looks bulky is due to my poor configuration, it is possible to cut it down and also take a screenshot I too find it hard to decide between Cypress or playwright. I tend to prefer Cypress in terms of the large number of users and well maintained documentation, but either is fine with me. I have two questions. |
I agree with the policy that what can be tested with wasm-pack should be tested with wasm-pack. |
I would prefer Playwright since the tests can be written in Rust. https://github.com/octaltree/playwright-rust by @octaltree exists but it seems it isn't maintained anymore: octaltree/playwright-rust#30
|
Sorry for the late reply and thanks for the introduction to a good repository. |
I have been having great experience with rust library Still it is not fully comparable as it only allows to use webdriver instead of being a full blown e2e testing framework like playwright or cypress. |
Thank you all for your comments! |
Description
I have created 3 e2e tests for todomvc using cypress. And i added to the README how to run the tests.
I would be glad if someone could review it. Thanks in advance.
Checklist