Skip to content

feat: Add TypeScript example. - #515

Merged
chrisbreiding merged 19 commits into
cypress-io:5.0.0from
sainthkh:ts
Aug 19, 2020
Merged

feat: Add TypeScript example.#515
chrisbreiding merged 19 commits into
cypress-io:5.0.0from
sainthkh:ts

Conversation

@sainthkh

@sainthkh sainthkh commented Jul 1, 2020

Copy link
Copy Markdown
Contributor

@CLAassistant

CLAassistant commented Jul 1, 2020

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@sainthkh

sainthkh commented Jul 1, 2020

Copy link
Copy Markdown
Contributor Author

Waiting for fix in #512.

@sainthkh

sainthkh commented Jul 1, 2020

Copy link
Copy Markdown
Contributor Author

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

@jennifer-shehane
jennifer-shehane requested a review from bahmutov July 1, 2020 04:01
Comment thread examples/fundamentals__typescript/README.Md Outdated
Comment thread examples/fundamentals__typescript/cypress/integration/tests.spec.ts
Comment thread examples/fundamentals__typescript/tsconfig.json
Comment thread examples/fundamentals__typescript/cypress/types.d.ts

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

Copy link
Copy Markdown
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
Copy Markdown
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)
    })

@bahmutov bahmutov left a comment

Copy link
Copy Markdown
Contributor

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

bahmutov commented Jul 2, 2020

Copy link
Copy Markdown
Contributor

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

@sainthkh

sainthkh commented Jul 3, 2020

Copy link
Copy Markdown
Contributor Author

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

@jennifer-shehane
jennifer-shehane requested a review from bahmutov July 6, 2020 04:52
Comment thread examples/fundamentals__typescript/cypress/types.d.ts
Comment thread examples/fundamentals__typescript/cypress/types.d.ts
Comment thread examples/fundamentals__typescript/cypress/types.d.ts
@flotwig flotwig mentioned this pull request Jul 6, 2020
21 tasks
@jennifer-shehane
jennifer-shehane requested a review from bahmutov July 7, 2020 05:39

@bahmutov bahmutov left a comment

Copy link
Copy Markdown
Contributor

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.

4 participants