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

Cypress setup #2221

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

scottrosen14
Copy link

@scottrosen14 scottrosen14 commented Nov 21, 2024

Description

Fixes #2220

Changes

  • Created cypress config
  • Added appropriate scripts to package json
  • Wrote initial tests for US flow

Screenshots

Please include concise visuals (videos, screenshots, etc.) demonstrating the code in action and the impact of changes. Many on the team use a free tool called Loom to capture and share short clips, but feel free to utilize any tool you'd like. Screenshots of the code itself can also be helpful, but are usually not necessary.

Screenshot 2024-11-20 at 6 57 21 PM

Testing

Note: When using create-react-app, REACT_APP must be prepended to env var name.
When running smoke screen, you must add appropriate env vars for
REACT_APP_POLICYENGINE_DOMAIN

  • .env.development
  • .env.production

@scottrosen14 scottrosen14 force-pushed the cypress-setup branch 2 times, most recently from 3d420d7 to f8297be Compare November 21, 2024 01:54
@anth-volk
Copy link
Collaborator

Thank you very much for your initiative to spearhead this project and your contributions on this @scottrosen14. When you're ready for review, please feel free to request it from me, or let me know if you don't see an option to do so, and we'll get you the right permissions.

@scottrosen14
Copy link
Author

Hey @anth-volk this is ready for review

@anth-volk
Copy link
Collaborator

Thanks @scottrosen14! I will probably get around to this late tomorrow.

@anth-volk anth-volk self-requested a review November 23, 2024 00:57
@scottrosen14
Copy link
Author

Hey @anth-volk could you review this?

@@ -1 +1,14 @@
{}
{
"semi": true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious why you enabled these lint rules. Was this a file that wasn't meant to be merged? Do you feel these would be the best for our linting structure? Or is this personal preference?

Copy link
Collaborator

@anth-volk anth-volk left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this @scottrosen14! Getting this sort of end-to-end testing up and running is something we've been wanting to do for quite a while. Unfortunately, I wasn't able to actually get the tests running locally, and since these aren't integrated into the CI/CD structures, I also can't debug that way. I had a couple requests around integrating them in, as well as some questions around your changes to linting. Looking forward to hammering those out with you. Thank you very much!

"prepare-husky": "husky"
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"lint:fix": "npm run lint --fix && npm run format",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I understand where you're going with this code, but we use the linting code in our CI/CD structure, and at that point, we run npm run lint. As such, with these changes, the CI/CD won't capture any of the prettier run. I would either revert the lint scripts and lint-related changes or modify .github/workflows/pr.yaml.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you could give a little bit more insight into what you were shooting for with these script changes and the .prettierrc.json code, I think we could ensure the changes meet the needs of the repo.

"prepare-husky": "husky",
"cy:dev": "npm start & wait-on http://localhost:3000 && STAGE_ENV=development cypress run",
"cy:prod": "npm run build && STAGE_ENV=production cypress run",
"cy:dev:open": "npm start & wait-on http://localhost:3000 && STAGE_ENV=development cypress open",
Copy link
Collaborator

Choose a reason for hiding this comment

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

We currently use two relevant CI/CD scripts for testing:
.github/workflows/pr.yaml runs whenever a PR is opened, while .github/workflows/push.yaml runs whenever a PR is approved and pushed. Could you modify these to run the relevant scripts? I'm guessing that would mean running npm run cy:dev inside the PR workflow and cy:prod in the push, but I'm unfamiliar with Cypress, so would the open scripts be more correct here?

describe("PolicyEngine Homepage", () => {
const regexArg = /the\s(us|u\.s\.|usa|united states)/;

beforeEach(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

When I run these tests locally, none of the tests actually run, as I get this error here:

  Running:  home.cy.js                                                                      (1 of 1)


  PolicyEngine Homepage
    1) "before each" hook for "should redirect from root to US homepage by default"


  0 passing (747ms)
  1 failing

  1) PolicyEngine Homepage
       "before each" hook for "should redirect from root to US homepage by default":
     CypressError: `cy.visit()` failed trying to load:

/

We failed looking for this file at the path:

/Users/administrator/Documents/forks/scottrosen14/policyengine-app/

The internal Cypress web server responded with:

  > 404: Not Found

I admit, it may be my setup, as I'm unfamiliar with Cypress, but wanted to highlight this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: PR: Review Requested
Development

Successfully merging this pull request may close these issues.

Cypress: Set up development environment
2 participants