feat: Add TypeScript example.#515
Conversation
|
Waiting for fix in #512. |
|
TypeScript test should fail until cypress/cypress#7806 is merged. |
use "on" redirect
|
|
||
| before(() => { | ||
| // @ts-expect-error | ||
| window.add = (a, b) => a + b |
There was a problem hiding this comment.
move it to fixtures test.html file :)
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
|
oh, one more thing - the example folder itself needs a README file with at least the basic description |
|
Detailed explanation is in the official doc site. So, I made it simple here. |
bahmutov
left a comment
There was a problem hiding this comment.
I think this looks good
For cypress-io/cypress#7806