Skip to content
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

Introduction to E2E testing with cypress #146

Merged
merged 9 commits into from
Nov 25, 2023
Merged

Introduction to E2E testing with cypress #146

merged 9 commits into from
Nov 25, 2023

Conversation

bw55555
Copy link
Contributor

@bw55555 bw55555 commented Nov 21, 2023

Added some resources about learning how to install, setup and use cypress, and an example use case.

Comment on lines 7 to 11
# Why do end to end testing?

[https://circleci.com/blog/what-is-end-to-end-testing/](https://circleci.com/blog/what-is-end-to-end-testing/)

The above link has a good explanation on what end to end testing is and why it should be used.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than just providing a link, it might be better to also provide a summary of the main points of the linked article explaining the importance of end-to-end testing. This way, the reader could get a quick understanding without needing to navigate away, and if they wanted to learn more, they could then click the provided link.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a great idea, added that


The above link has a good explanation on what end to end testing is and why it should be used.

Cypress very closely mimics a real user, think of it as a robot accessing your website from a browser like a human would, but you can program the robot to interact with your website however you like and programmatically check the output on the screen.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be beneficial to add a comparison with other testing tools after this section, to highlight the strengths and weaknesses of Cypress. Or, even after the "Best Practices" section.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a great idea

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if this section is hard to understand.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's easy enough to understand. If you want, an example might also help explain.


# Installation and setup:

Cypress can be automatically installed with npm: `npm install cypress`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readers who may be unfamiliar with npm, it could be helpful to quickly describe why it is used for installation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't exactly agree with this, because npm is just so important for javascript and node.js that its even bundled with node, but I added a hyperlink for npm just in case.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, a hyperlink for npm is probably good enough.

Comment on lines 19 to 33
See [https://docs.cypress.io/guides/getting-started/installing-cypress](https://docs.cypress.io/guides/getting-started/installing-cypress) for more details.

To run cypress, we can use the command `npx cypress open` and follow the instructions provided on the UI.

See [https://docs.cypress.io/guides/getting-started/opening-the-app](https://docs.cypress.io/guides/getting-started/opening-the-app) for more details.

# The basics

Cypress has an extremely detailed guide for getting started, explains how to create and run tests, and there is also a lot of information linked as well.

[https://docs.cypress.io/guides/end-to-end-testing/writing-your-first-end-to-end-test](https://docs.cypress.io/guides/end-to-end-testing/writing-your-first-end-to-end-test)

[https://docs.cypress.io/guides/core-concepts/introduction-to-cypress](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress)

I highly recommend reading through the above two links, and the entirety of the core concepts section in the documentation. It gives a thorough introduction on how cypress works and how to use it to test your application.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of just recommending reading through the links, it might be better to additionally give a brief overview of what the reader can expect to find in each section. This could help the user better navigate around and understand what they will find.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this. There are many different sections in the core concepts section, so I didn't provide an overview of each of them (it'd probably get too long) and the titles are descriptive enough in my opinion

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Comment on lines 37 to 43
Cypress provides their own list of best practices here: [https://docs.cypress.io/guides/references/best-practices](https://docs.cypress.io/guides/references/best-practices)

One common use case for cypress (and UI testing in general) is to test responsiveness, does the UI look like it should in different viewports?

While it is possible to duplicate tests, this may cause you to need to repeat large parts of the code to select elements and fill out forms, which has nothing to do with

It is much easier to use the beforeEach() hook and a cypress context() to bundle viewpoints together. As an example:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way you describe a common use case after the link to the list of best practices, as well as provide an example is great! It could be helpful to add a few more key best practices, with concise explanations and examples. If you decide to do so, it might also be better for organization to break down this part into subsections.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I didn't add more key practices, as I prefer to keep everything tied to one narrative (the use case) I did add more to the single use case I had and moved the link to the back as well for further reading.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, if you want to just focus on the narrative of the use case, then what you have here seems sufficient.

@bw55555
Copy link
Contributor Author

bw55555 commented Nov 23, 2023

I addressed all the comments, I think most of them made sense but some of them I didn't, I wrote down in each comment which ones I took and which ones I didn't.

@bw55555 bw55555 requested a review from ajsjiang November 23, 2023 16:15
Copy link

@ajsjiang ajsjiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than my new suggestion to possibly add an example in the "Why do end to end testing" section, I think you could also consider adding a table of contents once you have finalized all of your sections. Good work with the changes and addressing my comments!


The above link has a good explanation on what end to end testing is and why it should be used.

Cypress very closely mimics a real user, think of it as a robot accessing your website from a browser like a human would, but you can program the robot to interact with your website however you like and programmatically check the output on the screen.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's easy enough to understand. If you want, an example might also help explain.

Comment on lines 19 to 33
See [https://docs.cypress.io/guides/getting-started/installing-cypress](https://docs.cypress.io/guides/getting-started/installing-cypress) for more details.

To run cypress, we can use the command `npx cypress open` and follow the instructions provided on the UI.

See [https://docs.cypress.io/guides/getting-started/opening-the-app](https://docs.cypress.io/guides/getting-started/opening-the-app) for more details.

# The basics

Cypress has an extremely detailed guide for getting started, explains how to create and run tests, and there is also a lot of information linked as well.

[https://docs.cypress.io/guides/end-to-end-testing/writing-your-first-end-to-end-test](https://docs.cypress.io/guides/end-to-end-testing/writing-your-first-end-to-end-test)

[https://docs.cypress.io/guides/core-concepts/introduction-to-cypress](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress)

I highly recommend reading through the above two links, and the entirety of the core concepts section in the documentation. It gives a thorough introduction on how cypress works and how to use it to test your application.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.


# Installation and setup:

Cypress can be automatically installed with npm: `npm install cypress`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, a hyperlink for npm is probably good enough.

Comment on lines 37 to 43
Cypress provides their own list of best practices here: [https://docs.cypress.io/guides/references/best-practices](https://docs.cypress.io/guides/references/best-practices)

One common use case for cypress (and UI testing in general) is to test responsiveness, does the UI look like it should in different viewports?

While it is possible to duplicate tests, this may cause you to need to repeat large parts of the code to select elements and fill out forms, which has nothing to do with

It is much easier to use the beforeEach() hook and a cypress context() to bundle viewpoints together. As an example:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, if you want to just focus on the narrative of the use case, then what you have here seems sufficient.

@bw55555
Copy link
Contributor Author

bw55555 commented Nov 25, 2023

I added the table of contents since I thought it was a good idea, and made some other housekeeping changes. Let me know what you think, is it ready to merge?

@bw55555 bw55555 requested a review from ajsjiang November 25, 2023 02:40
Copy link

@ajsjiang ajsjiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I think you are ready to merge!

@bw55555 bw55555 merged commit 8ab7235 into main Nov 25, 2023
@bw55555 bw55555 deleted the bw55555/cypress branch November 25, 2023 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants