Skip to content

Commit

Permalink
chore: add type linting + compilation checks to packages (#30776)
Browse files Browse the repository at this point in the history
* chore: add type linting + compilation checks to runner package

* empty commit

* A bunch of tslint fixes

* wow it is building

* Fix issue with CT not mounting correctly with comments within it

* Fix net-stubbing.ct.ts failures

* Fix tslint: disable comment

* move target into compilerOptions

* fix tslint disable comment

* update proxy-logging to undo changes

* standardize the tslint:disable comments

* fix comment

* fix the banner content not displaying and write a test for this situation

* fix ct reference

* put target to es2020

* actually set the property with replaced title

* Update packages/reporter/src/hooks/hook-model.ts

Co-authored-by: Ryan Manuel <ryanm@cypress.io>

* Fix eslint/tslint settings for system-tests with vue 3

* bump CI cache

* update types/react resolution

* add return

* lint fix

* tslint disable for empty blocks

* exclude dist files from ts linting

* update to exclude all dist folder

* exclude dist file

* change to await

* fix line numbers of stack trace with linting updating vue file

---------

Co-authored-by: Ryan Manuel <ryanm@cypress.io>
  • Loading branch information
jennifer-shehane and ryanthemanuel authored Jan 23, 2025
1 parent 3149a8f commit 92e428a
Show file tree
Hide file tree
Showing 134 changed files with 601 additions and 416 deletions.
2 changes: 1 addition & 1 deletion .circleci/cache-version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Bump this version to force CI to re-create the cache from scratch.

1-15-24
1-17-24
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@
"**/sharp": "0.29.3",
"**/socket.io-parser": "4.0.5",
"**/ua-parser-js": "0.7.33",
"@types/react": "18.3.12",
"browserify-sign": "4.2.2",
"devtools-protocol": "0.0.1346313",
"sharp": "0.29.3",
Expand Down
12 changes: 6 additions & 6 deletions packages/app/cypress/e2e/runner/ct-framework-errors.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ describe('Vue', {

verify('error on mount', {
fileName: 'Errors.vue',
line: 19,
column: 15,
line: 29,
column: 13,
message: [
'mount error',
],
Expand All @@ -231,8 +231,8 @@ describe('Vue', {

verify('sync error', {
fileName: 'Errors.vue',
line: 24,
column: 15,
line: 34,
column: 13,
uncaught: true,
uncaughtMessage: 'sync error',
message: [
Expand All @@ -246,8 +246,8 @@ describe('Vue', {

verify('async error', {
fileName: 'Errors.vue',
line: 28,
column: 17,
line: 38,
column: 15,
uncaught: true,
uncaughtMessage: 'async error',
message: [
Expand Down
3 changes: 2 additions & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"build": "vite build",
"check-ts": "vue-tsc --noEmit",
"check-ts": "vue-tsc --noEmit && yarn -s tslint",
"clean": "rimraf dist && echo 'cleaned'",
"clean-deps": "rimraf node_modules",
"cypress:launch": "yarn cypress:run-cypress-in-cypress gulp open --project .",
Expand All @@ -17,6 +17,7 @@
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .",
"start": "echo \"run 'yarn dev' or 'yarn watch' from the root\" && exit 1",
"test": "echo 'ok'",
"tslint": "tslint --config ../ts/tslint.json --project .",
"watch": "echo \"run 'yarn dev' or 'yarn watch' from the root\" && exit 1"
},
"dependencies": {},
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/composables/useCloudSpecData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ export function useCloudSpecData (
*/
watch(
[debouncedDisplayedSpecIds, isOffline, isProjectDisconnected, mostRecentUpdate],
() => {
fetchDisplayedCloudData()
async () => {
await fetchDisplayedCloudData()
},
{ flush: 'post' },
)
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/composables/usePreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export function usePreferences () {
const runnerUiStore = useRunnerUiStore()
const setPreferences = useMutation(Preferences_SetPreferencesDocument)

function update<K extends keyof RunnerUiState> (preference: K, value: RunnerUiState[K]) {
async function update<K extends keyof RunnerUiState> (preference: K, value: RunnerUiState[K]) {
if (runnerUiStore[preference] !== value) {
// only set the value and trigger the mutation if the value has actually changed
runnerUiStore.setPreference(preference, value)
setPreferences.executeMutation({ value: JSON.stringify({ [preference]: value }) })
await setPreferences.executeMutation({ value: JSON.stringify({ [preference]: value }) })
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/composables/useRecordEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type EventParams = {
export function useRecordEvent () {
const recordEventMutation = useMutation(UseRecordEvent_RecordEventDocument)

function record (params: EventParams) {
recordEventMutation.executeMutation({
async function record (params: EventParams) {
await recordEventMutation.executeMutation({
...params,
messageId: nanoid(),
includeMachineId: params.includeMachineId ?? false,
Expand Down
9 changes: 5 additions & 4 deletions packages/app/src/composables/useSpecFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@ export function useSpecFilter (savedFilter?: string) {

const debouncedSpecFilterModel = useDebounce(specFilterModel, 200)

function setSpecFilter (specFilter: string) {
async function setSpecFilter (specFilter: string) {
if (specStore.specFilter !== specFilter) {
specStore.setSpecFilter(specFilter)
saveSpecFilter.executeMutation({ value: JSON.stringify({ specFilter }) })
await saveSpecFilter.executeMutation({ value: JSON.stringify({ specFilter }) })
}
}

watch(() => debouncedSpecFilterModel?.value, (newVal) => {
setSpecFilter(newVal ?? '')
watch(() => debouncedSpecFilterModel?.value, async (newVal) => {
await setSpecFilter(newVal ?? '')
})

// initialize spec filter in store
// tslint:disable:no-floating-promises
setSpecFilter(specFilterModel.value)

return {
Expand Down
14 changes: 7 additions & 7 deletions packages/app/src/composables/useTestingType.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('useTestingType', () => {
})

it('supplies expected query data', () => {
mountComposable(useTestingType).then((value) => {
mountComposable(useTestingType).then(async (value) => {
const result = value as unknown as ReturnType<typeof useTestingType>

expect(result.activeTestingType.value).to.eql('e2e')
Expand All @@ -69,12 +69,12 @@ describe('useTestingType', () => {
})

it('should toggle viewed mode', () => {
mountComposable(useTestingType).then((value) => {
mountComposable(useTestingType).then(async (value) => {
const result = value as unknown as ReturnType<typeof useTestingType>

expect(result.viewedTestingType.value).to.eql('e2e')

result.viewTestingType('component')
await result.viewTestingType('component')

expect(result.viewedTestingType.value).to.eql('component')
})
Expand All @@ -92,24 +92,24 @@ describe('useTestingType', () => {
})

it('should toggle active mode if not active mode', () => {
mountComposable(useTestingType).then((value) => {
mountComposable(useTestingType).then(async (value) => {
const result = value as unknown as ReturnType<typeof useTestingType>

expect(result.viewedTestingType.value).to.eql('e2e')

result.viewTestingType('component')
await result.viewTestingType('component')
})

cy.get('@activateTestingType').should('have.been.calledOnce')
})

it('should toggle viewed mode if active mode', () => {
mountComposable(useTestingType).then((value) => {
mountComposable(useTestingType).then(async (value) => {
const result = value as unknown as ReturnType<typeof useTestingType>

expect(result.viewedTestingType.value).to.eql('e2e')

result.viewTestingType('e2e')
await result.viewTestingType('e2e')
})

cy.get('@activateTestingType').should('not.have.been.called')
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ app.use(Toast, {
closeOnClick: false,
})

makeUrqlClient({ target: 'app', namespace: config.namespace, socketIoRoute: config.socketIoRoute }).then((client) => {
await makeUrqlClient({ target: 'app', namespace: config.namespace, socketIoRoute: config.socketIoRoute }).then((client) => {
app.use(urql, client)
app.use(createRouter())
app.use(createI18n())
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/runner/event-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -875,9 +875,9 @@ export class EventManager {
}

_studioCopyToClipboard (cb) {
this.ws.emit('studio:get:commands:text', this.studioStore.logs, (commandsText) => {
this.studioStore.copyToClipboard(commandsText)
.then(cb)
this.ws.emit('studio:get:commands:text', this.studioStore.logs, async (commandsText) => {
await this.studioStore.copyToClipboard(commandsText)
cb()
})
}

Expand Down
20 changes: 10 additions & 10 deletions packages/app/src/runner/events/capture-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const addCaptureProtocolListeners = (Cypress: Cypress.Cypress) => {
})
})

Cypress.on('log:added', (attributes) => {
Cypress.on('log:added', async (attributes) => {
// TODO: UNIFY-1318 - Race condition in unified runner - we should not need this null check
if (!Cypress.runner) {
return
Expand All @@ -38,10 +38,10 @@ export const addCaptureProtocolListeners = (Cypress: Cypress.Cypress) => {
timestamp: performance.now() + performance.timeOrigin,
})

Cypress.backend('protocol:command:log:added', protocolProps)
await Cypress.backend('protocol:command:log:added', protocolProps)
})

Cypress.on('log:changed', (attributes) => {
Cypress.on('log:changed', async (attributes) => {
// TODO: UNIFY-1318 - Race condition in unified runner - we should not need this null check
if (!Cypress.runner) {
return
Expand All @@ -54,18 +54,18 @@ export const addCaptureProtocolListeners = (Cypress: Cypress.Cypress) => {
timestamp: performance.now() + performance.timeOrigin,
})

Cypress.backend('protocol:command:log:changed', protocolProps)
await Cypress.backend('protocol:command:log:changed', protocolProps)
})

const viewportChangedHandler = (viewport) => {
const viewportChangedHandler = async (viewport) => {
const timestamp = performance.timeOrigin + performance.now()

attachCypressProtocolInfo({
type: 'viewport:changed',
timestamp,
})

Cypress.backend('protocol:viewport:changed', {
await Cypress.backend('protocol:viewport:changed', {
viewport: {
width: viewport.viewportWidth,
height: viewport.viewportHeight,
Expand All @@ -92,26 +92,26 @@ export const addCaptureProtocolListeners = (Cypress: Cypress.Cypress) => {
})
})

Cypress.on('url:changed', (url) => {
Cypress.on('url:changed', async (url) => {
const timestamp = performance.timeOrigin + performance.now()

attachCypressProtocolInfo({
type: 'url:changed',
timestamp,
})

Cypress.backend('protocol:url:changed', { url, timestamp })
await Cypress.backend('protocol:url:changed', { url, timestamp })
})

Cypress.on('page:loading', (loading) => {
Cypress.on('page:loading', async (loading) => {
const timestamp = performance.timeOrigin + performance.now()

attachCypressProtocolInfo({
type: 'page:loading',
timestamp,
})

Cypress.backend('protocol:page:loading', { loading, timestamp })
await Cypress.backend('protocol:page:loading', { loading, timestamp })
})

Cypress.on('test:before:after:run:async', async (attributes, _test, options) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/runner/unifiedRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export function useUnifiedRunner () {
initialized.value = true
})

onBeforeUnmount(() => {
UnifiedRunnerAPI.teardown()
onBeforeUnmount(async () => {
await UnifiedRunnerAPI.teardown()
initialized.value = false
})

Expand Down
20 changes: 10 additions & 10 deletions packages/app/src/runner/useEventManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ export function useEventManager () {
const studioStore = useStudioStore()
const router = useRouter()

function runSpec (isRerun: boolean = false) {
async function runSpec (isRerun: boolean = false) {
if (!specStore.activeSpec) {
throw Error(`Cannot run spec when specStore.active spec is null or undefined!`)
}

autStore.setScriptError(null)
UnifiedRunnerAPI.executeSpec(specStore.activeSpec, isRerun)
await UnifiedRunnerAPI.executeSpec(specStore.activeSpec, isRerun)
}

function initializeRunnerLifecycleEvents () {
// these events do not use GraphQL
eventManager.on('restart', () => {
eventManager.on('restart', async () => {
// If we get the event to restart but have already navigated away from the runner, don't execute the spec
if (specStore.activeSpec) {
const isRerun = true

runSpec(isRerun)
await runSpec(isRerun)
}
})

Expand All @@ -49,8 +49,8 @@ export function useEventManager () {
getAutIframeModel().reattachStudio()
})

eventManager.on('visit:blank', ({ testIsolation }) => {
return getAutIframeModel().visitBlankPage(testIsolation)
eventManager.on('visit:blank', async ({ testIsolation }) => {
await getAutIframeModel().visitBlankPage(testIsolation)
})

eventManager.on('run:end', () => {
Expand All @@ -61,20 +61,20 @@ export function useEventManager () {

eventManager.on('expect:origin', addCrossOriginIframe)

eventManager.on('testFilter:cloudDebug:dismiss', () => {
eventManager.on('testFilter:cloudDebug:dismiss', async () => {
const currentRoute = router.currentRoute.value

const { mode, ...query } = currentRoute.query

// Delete runId from query which will remove the test filter and trigger a rerun
router.replace({ ...currentRoute, query })
await router.replace({ ...currentRoute, query })
})
}

const startSpecWatcher = () => {
return watch(() => specStore.activeSpec, () => {
return watch(() => specStore.activeSpec, async () => {
if (specStore.activeSpec) {
runSpec()
await runSpec()
}
}, { immediate: true, flush: 'post' })
}
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/runner/useRunnerStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ export const useRunnerStyle = () => {
export function useResizablePanels () {
const preferences = usePreferences()

const handleResizeEnd = (panel: DraggablePanel) => {
const handleResizeEnd = async (panel: DraggablePanel) => {
if (panel === 'panel1') {
preferences.update('specListWidth', specListWidth.value)
await preferences.update('specListWidth', specListWidth.value)
} else {
preferences.update('reporterWidth', reporterWidth.value)
await preferences.update('reporterWidth', reporterWidth.value)
}
}

Expand Down
5 changes: 3 additions & 2 deletions packages/app/src/runs/useProjectRuns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const useProjectRuns = (online: Ref<boolean>): RunsComposable => {
function startPolling () {
timeout = window.setTimeout(function fetchNewerRuns () {
if (variables.value && online.value) {
// tslint:disable:no-floating-promises
refetcher.executeMutation(variables.value)
.then(() => {
startPolling()
Expand All @@ -100,10 +101,10 @@ export const useProjectRuns = (online: Ref<boolean>): RunsComposable => {
}, POLL_FOR_LATEST)
}

onMounted(() => {
onMounted(async () => {
// Always fetch when the component mounts, and we're not already fetching
if (online.value && !refetcher.fetching) {
refetcher.executeMutation(variables.value)
await refetcher.executeMutation(variables.value)
}

startPolling()
Expand Down
Loading

5 comments on commit 92e428a

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 92e428a Jan 23, 2025

Choose a reason for hiding this comment

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

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/14.0.1/linux-x64/develop-92e428a3575234f623ec020b17b11a50f2d4d8d6/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 92e428a Jan 23, 2025

Choose a reason for hiding this comment

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

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/14.0.1/linux-arm64/develop-92e428a3575234f623ec020b17b11a50f2d4d8d6/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 92e428a Jan 23, 2025

Choose a reason for hiding this comment

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

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/14.0.1/darwin-arm64/develop-92e428a3575234f623ec020b17b11a50f2d4d8d6/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 92e428a Jan 23, 2025

Choose a reason for hiding this comment

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

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/14.0.1/win32-x64/develop-92e428a3575234f623ec020b17b11a50f2d4d8d6/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 92e428a Jan 23, 2025

Choose a reason for hiding this comment

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

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/14.0.1/darwin-x64/develop-92e428a3575234f623ec020b17b11a50f2d4d8d6/cypress.tgz

Please sign in to comment.