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

Set up Cypress and configure local test environment #829

Merged
merged 8 commits into from
Jul 31, 2024

Conversation

aialok
Copy link
Collaborator

@aialok aialok commented Jul 26, 2024

What kind of change does this PR introduce?
This PR introduces the following changes:

  • Initial Cypress setup with ESLint plugin
  • Cypress code coverage
  • Initial dummy e2e test (currently commented out)
  • Test for Card component with 100% code coverage
  • New cypress folder structure for test management (natively provided by cypress)

Issue Number:

Screenshots/videos:

Screencast.from.2024-07-27.01-32-12.webm

Code Coverage Report:
image

If relevant, did you update the documentation?

Note:

  • All testing-related files and folders are inside the cypress folder. These include Cypress configurations and two subfolders: 'e2e' and 'components' for end-to-end and component testing, respectively.
  • This PR includes a basic e2e test file for testing purposes only, which will be removed soon.

Does this PR introduce a breaking change?

@aialok aialok added the GSoC Google Summer of Code related label Jul 26, 2024
@aialok aialok requested a review from a team as a code owner July 26, 2024 20:26
@aialok
Copy link
Collaborator Author

aialok commented Jul 26, 2024

Setting up this was literally quite challenging. It was easy to setup Cypress and write tests but the code coverage part took really some good amount of time.
The problem was that Cypress code coverage uses Babel compiler for js/ts while Next.js used SWC compiler. So when configuring Cypress code coverage with Istanbul (a tool for code coverage reporting) we needed to setup .babelrc files. Because of .babelrc file Next.js started using Babel compiler instead of SWC compiler and most of Next.js parts started failing because they are compatible with SWC compiler. It literally took me more than one day and 100+ tabs - blogs, GitHub issues and discussions, and Cypress Discord but could not find any good solution and this is still the problem that exists.

So after lots of struggle I found a little hacky solution. Basically I found one guy who commented that if you use Babel in package.json then Next.js will not be able to find Babel config and will use SWC compiler. And boom, it works.

https://babeljs.io/docs/configuration#packagejson

Copy link

github-actions bot commented Jul 31, 2024

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
website ✅ Ready (View Log) Visit Preview 8173496

Copy link
Collaborator

@benjagm benjagm left a comment

Choose a reason for hiding this comment

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

Great job. I dont have comments... only KUDOS!!

Lets merge this!!

@benjagm benjagm merged commit f6dff53 into json-schema-org:main Jul 31, 2024
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GSoC Google Summer of Code related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create tests for components/Card.tsx Set up Cypress and configure local test environment
2 participants