-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
chore: add type linting + compilation checks to packages #30776
base: develop
Are you sure you want to change the base?
Conversation
cypress Run #59376
Run Properties:
|
Project |
cypress
|
Branch Review |
runner-check-ts
|
Run status |
Passed #59376
|
Run duration | 20m 28s |
Commit |
1daefcfce3: Update packages/reporter/src/hooks/hook-model.ts
|
Committer | Jennifer Shehane |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
3
|
Pending |
1326
|
Skipped |
0
|
Passing |
29270
|
View all changes introduced in this branch ↗︎ |
UI Coverage
46.11%
|
|
---|---|
Untested elements |
189
|
Tested elements |
166
|
Accessibility
92.54%
|
|
---|---|
Failed rules |
3 critical
8 serious
2 moderate
2 minor
|
Failed elements |
906
|
… into runner-check-ts
defaultMessages.specPage.banners.componentTesting.title = ctBannerTitle.replace('{0}', 'React') | ||
} | ||
|
||
cy.wrap(Object.entries(defaultMessages.specPage.banners[camelCase(bannerTestId)])).each((entry) => { |
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 added this assertion because after my updates, the rendering of the banner content was broken, but I only detected this through Percy. We should have a test that asserts on the content for the future.
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.
Looks good! Most comments are about noting why the floating promises rule is disabled when it is, some potentially unnecessary async/await
patterns, and unwrapping .then
s in async
functions. Nothing show-stopping!
}) | ||
|
||
// initialize spec filter in store | ||
// tslint:disable:no-floating-promises |
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 add a comment about why the floating promise rule is disabled?
@@ -1749,6 +1749,7 @@ describe('network stubbing', { retries: 15 }, function () { | |||
}).as('create') | |||
|
|||
cy.then(() => { | |||
// tslint:disable:no-floating-promises |
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 the fetch()
be return
ed? That way the cy.then
will wait for the promise to be resolved ... unless that introduces flake?
@@ -50,6 +50,7 @@ describe('Proxy Logging', () => { | |||
// TODO(webkit): fix+unskip for webkit release | |||
browser: '!webkit', | |||
}, (done) => { | |||
// tslint:disable:no-floating-promises | |||
fetch('/some-url') |
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.
would cy.wrap
cause issues with the test?
@@ -212,6 +212,7 @@ describe('cy.origin Cypress API', { browser: '!webkit' }, () => { | |||
}) | |||
|
|||
cy.origin('http://www.foobar.com:3500', () => { | |||
// tslint:disable:no-floating-promises |
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.
cy.then(Cypress.session.clearCurrentSessionData)
maybe?
@@ -309,6 +309,7 @@ describe('src/cross-origin/patches', { browser: '!webkit', defaultCommandTimeout | |||
let url = new URL('/test-request', 'http://app.foobar.com:3500').toString() | |||
|
|||
return new Promise<void>((resolve, reject) => { | |||
// tslint:disable:no-floating-promises | |||
fetch(url, { |
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.
fetch
itself returns a promise, creating a promise here isn't really necessary, just return fetch()
// only send up page loading events when we're | ||
// not stable! | ||
stabilityChanged(Cypress, state, config, bool) | ||
await stabilityChanged(Cypress, state, config, bool) |
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.
changing to async
/await
can add an unnecessary promise layer - will just return stabilityChanged(..etc)
work?
@@ -22,14 +22,14 @@ export class CDPBrowserSocket extends Emitter implements SocketShape { | |||
|
|||
this._namespace = namespace | |||
|
|||
const send = (payload: string) => { | |||
const send = async (payload: string) => { |
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 may be a little easier to read:
const send = async (payload: string) => {
const parsed = JSON.parse(payload)
const [event, callbackEvent, args] = await decode(parsed)
super.emit(event, ...args)
await this.emit(callbackEvent)
}
@@ -65,7 +66,7 @@ export class CDPBrowserSocket extends Emitter implements SocketShape { | |||
this.once(uuid, callback) | |||
} | |||
|
|||
encode([event, uuid, args], this._namespace).then((encoded: any) => { | |||
await encode([event, uuid, args], this._namespace).then((encoded: any) => { |
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.
same as above - since this fn is changing to async/await, it's a good time to unwrap the .then
@@ -1,7 +1,7 @@ | |||
{ | |||
"compilerOptions": { | |||
/* Basic Options */ | |||
"target": "es2015", | |||
"target": "es2017", |
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.
es2022
doesn't work here?
@@ -24,4 +24,5 @@ async function build () { | |||
await fs.remove(iconsetPath) | |||
} | |||
|
|||
// tslint:disable:no-floating-promises | |||
build() |
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.
We could do something like this for better error handling here (and to get rid of the tslint:disable)
build() | |
build().then(() => { | |
console.log('icons successfully built') | |
}).catch((error) => { | |
console.log('icons failed to build', error) | |
}) |
@@ -11,6 +11,7 @@ const files = [ | |||
fs.readFileSync('./assets/icons/icon_256x256.png'), | |||
] | |||
|
|||
// tslint:disable:no-floating-promises |
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.
Same thing here. Could add some error handling.
Co-authored-by: Ryan Manuel <[email protected]>
Additional details
We aren't running typescript linting or compilation checks in many of our packages, so this is meant to remedy some of that. There were a lot of failures.
NOTE: This does not include running
tsc
on therunner
package since there were a lot more errors, but it is running tslint. See here: https://github.com/cypress-io/cypress/pull/30776/files#diff-3f56f0ca38e3b8dff3d2436a8f56f2cfb94120eeaa9af84182dce52d8a87d751R10Steps to test
How has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?