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 test #159

Merged
merged 5 commits into from
Jun 27, 2022
Merged

Cypress test #159

merged 5 commits into from
Jun 27, 2022

Conversation

huyenuet
Copy link
Contributor

@huyenuet huyenuet commented Jun 25, 2022

Features

  • Add more tests for other pages on the Docs website

huyenuet added 2 commits June 25, 2022 22:23
@netlify
Copy link

netlify bot commented Jun 25, 2022

Deploy Preview for jest-preview-library canceled.

Name Link
🔨 Latest commit 2800062
🔍 Latest deploy log https://app.netlify.com/sites/jest-preview-library/deploys/62b98ec405f3d800086f7031

@nvh95
Copy link
Owner

nvh95 commented Jun 25, 2022

@huyenuet Can you elaborate more on Disable chromeWebSecurity to test an URL opened in a new tab? Thanks.

Comment on lines 7 to 39
it('Check CTA Get Started button if it works', () => {
cy.get('.button').click()
cy.url()
.should('contain', 'docs/getting-started/intro')
cy.contains('h1','Introduction')
})

it('Check Docs page is present', () => {
cy.contains("Docs").click()
cy.url()
.should('contain', 'docs/getting-started/intro')
cy.contains('h1','Introduction')
})

it('Check Blog page is present', () => {
cy.contains("Blog").click()
cy.url()
.should('contain', '/blog')
cy.contains('Recent posts')
})

it('Check API page is present', () => {
cy.contains("API").click()
cy.url()
.should('contain', '/api')
cy.contains('Getting Started')
})

it('Check Demo link is correct and Demo page is present', () => {
cy.contains('Demo').invoke('removeAttr', 'target').click()
cy.url()
.should('include', 'stackblitz.com/edit/jest-preview')
cy.contains('Jest Preview')
Copy link
Owner

Choose a reason for hiding this comment

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

@huyenuet With this style of writing tests. Cypress needs to visit https://www.jest-preview.com 5 times.
Instead, you can visit it only 1 time, then navigate and assert 5 times. That would make your tests run much faster (especially in a CI environment)

@@ -4,6 +4,7 @@ export default defineConfig({
e2e: {
supportFile: "support/e2e.{js,jsx,ts,tsx}",
specPattern: "e2e/**/*.cy.{js,jsx,ts,tsx}",
chromeWebSecurity: false,
Copy link
Owner

Choose a reason for hiding this comment

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

Can you elaborate more (and the reference link would be great)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a workaround recommended by Crypess to handle the superdomain switch limitation. But I've just read more about this, and it turns out there are more solutions for this problem. Disabling ChromeWebSecurity is the least recommended.
You can read more about this here

  1. Workaround for External Navigation
  2. Disabling-Web-Security

@nvh95
Copy link
Owner

nvh95 commented Jun 25, 2022

@huyenuet Hey you haven't configured your email to associated with your commits, so your name will not appear in the contributor list.

Please fix this by referring to https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-email-preferences/setting-your-commit-email-address#setting-your-commit-email-address-in-git

@huyenuet
Copy link
Contributor Author

@nvh95 I updated per your comments. Please check, thanks!

Copy link
Owner

@nvh95 nvh95 left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines 34 to 38
// pull off the fully qualified href from the <a>
const url = $a.prop('href')

// make a cy.request to it
cy.request(url).its('body').should('include', 'Jest Preview')
Copy link
Owner

Choose a reason for hiding this comment

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

@huyenuet Actually, we don't need to verify stackblitz.com. Asserting the URL is enough in this case.

@nvh95 nvh95 merged commit ef249e0 into nvh95:main Jun 27, 2022
@nvh95
Copy link
Owner

nvh95 commented Jun 27, 2022

Thanks for your help @huyenuet.

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