-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
Cypress test #159
Conversation
This change is for testing an url opened in a new tab
✅ Deploy Preview for jest-preview-library canceled.
|
@huyenuet Can you elaborate more on |
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') |
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.
@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)
docs-e2e-testing/cypress.config.ts
Outdated
@@ -4,6 +4,7 @@ export default defineConfig({ | |||
e2e: { | |||
supportFile: "support/e2e.{js,jsx,ts,tsx}", | |||
specPattern: "e2e/**/*.cy.{js,jsx,ts,tsx}", | |||
chromeWebSecurity: false, |
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.
Can you elaborate more (and the reference link would be great)?
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.
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
@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 |
@nvh95 I updated per your comments. Please check, thanks! |
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.
LGTM!
// 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') |
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.
@huyenuet Actually, we don't need to verify stackblitz.com
. Asserting the URL is enough in this case.
Thanks for your help @huyenuet. |
Features