-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
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.
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 :)
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.
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)
})
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.
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. |
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.
I think this looks good
For cypress-io/cypress#7806