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

feat: Add TypeScript example. #515

Merged
merged 19 commits into from Aug 19, 2020
Merged

feat: Add TypeScript example. #515

merged 19 commits into from Aug 19, 2020

Conversation

sainthkh
Copy link
Contributor

@sainthkh sainthkh commented Jul 1, 2020

@CLAassistant
Copy link

CLAassistant commented Jul 1, 2020

CLA assistant check
All committers have signed the CLA.

@sainthkh
Copy link
Contributor Author

sainthkh commented Jul 1, 2020

Waiting for fix in #512.

@sainthkh
Copy link
Contributor Author

sainthkh commented Jul 1, 2020

TypeScript test should fail until cypress/cypress#7806 is merged.


before(() => {
// @ts-expect-error
window.add = (a, b) => a + b
Copy link
Contributor

Choose a reason for hiding this comment

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

move it to fixtures test.html file :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It cannot be removed entirely because it shows that the type of Test Runner window fails because it's not extended.

I rewrote the test like below:

  it('test extending AUTWindow', () => {
    // Test Runner window object doesn't have add() function.
    // So, it should fail the type check.
    // @ts-expect-error
    window.add = (a, b) => a + b

    cy.window().then((win) => {
      // AUT add() is defined in the fixture, test.html.
      // So, it should pass the type check.
      return win.add(2, 3)
    })

Copy link
Contributor

@bahmutov bahmutov left a comment

Choose a reason for hiding this comment

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

almost good - just need to move the window.add into the application's HTML file <script>...</script> tag, no need to confuse the matter by adding it to the before in the spec file

@bahmutov
Copy link
Contributor

bahmutov commented Jul 2, 2020

oh, one more thing - the example folder itself needs a README file with at least the basic description

@sainthkh
Copy link
Contributor Author

sainthkh commented Jul 3, 2020

Detailed explanation is in the official doc site. So, I made it simple here.

Copy link
Contributor

@bahmutov bahmutov left a comment

Choose a reason for hiding this comment

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

I think this looks good

@chrisbreiding chrisbreiding changed the title TypeScript example. feat: Add TypeScript example. Aug 19, 2020
@chrisbreiding chrisbreiding merged commit 86d0f7d into cypress-io:5.0.0 Aug 19, 2020
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.

None yet

4 participants