-
Notifications
You must be signed in to change notification settings - Fork 8.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
feat: introduce cypress e2e tests #9520
base: main
Are you sure you want to change the base?
feat: introduce cypress e2e tests #9520
Conversation
9f8c95d
to
b19a88c
Compare
b19a88c
to
eba2e7d
Compare
@iamjoel Please take a look at this. |
@AkaraChen Please take a look at this. |
@perzeuss maybe remove https://nextjs.org/docs/architecture/nextjs-compiler#remove-react-properties |
# && apt-get -y install --no-install-recommends <your-package-list-here> | ||
|
||
# Cypress dependencies - Cypress is our end-to-end testing tool |
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.
@takatost The frontend team rarely use devcontainer, and backend team don't care about e2e test, maybe remove these change will be better?
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 your feedback! I understand the concerns about adding Cypress dependencies to the Dockerfile for the devcontainer. However, In my opinion, we have enough reasons to keep them:
- We have frontend developers in the open-source community who may want to use the devcontainer for their contributions.
- The devcontainer serves as the base image for running the e2e tests in the CI pipeline.
- Even though the backend team may not prioritize end-to-end tests, it's essential for them to run these tests when making significant changes.
- Installing these dependencies doesn't take up much space or time, and since the devcontainer is rarely rebuilt, the impact on development workflows is negligible.
- Removing these dependencies adds another hurdle for contributors when it comes to running tests after making changes, which goes against the purpose of devcontainers. They are meant to provide a seamless development environment that just works, making it easier for everyone to contribute effectively.
I wouldn't recommend removing testids in production unless they cause problems. Keeping them in the production build can even be beneficial: they can assist in reporting bugs by helping to locate specific components, and they can also be used to run tests in the production environment. Apart from that, enabling a feature that uses regex to remove code comes with the risk that it will break things. |
Checklist:
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint godsDescription
As described in #9253, this PR introduces cypress e2e tests to test Dify features. The setup is using gherkin & cucumber to define test cases. This makes it easier to write tests in a more human-readable format and also acts as documentation for the features.
Type of Change
Testing Instructions
Run docker test environment an execute Cypress tests
/web
directory and runyarn
to install the dependenciesyarn test:e2e:ci
to run the cypress testsThe tests should pass and you should see the recorded videos in web/cypress/videos. Since the tests run fast, the videos will only be helpful if a test fails. If you want to generate videos that can be used as reference for docs, run
yarn test:e2e:docs
which will generate tests that are slower and allow to follow to what happens in the frontend.Opening the Cypress UI
For the development of tests, you would want to open the Cypress UI.
yarn cy:run
, an electron window should open where you can select the e2e test suite and run individual testsyarn cy:open:wsl
and use VcXsrv to connect to the VNC server and interact with the Cypress UI.GitHub Action
I've added a GitHub action to run the tests. For a performance boost, it will create and use a docker image as cache. For this we need to configure the secret
CYPRESS_CONTAINER_REGISTRY_TOKEN
(classic token withregistry:write
permission for docker push) and the variablesDOCKER_NAMESPACE
andDEVCONTAINER_IMAGE_NAME
in the repository settings.You can find a test run of the GitHub action here: https://github.com/perzeuss/dify/actions/runs/11428886478