Skip to content
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: convert xhrs js to ts #30935

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open

chore: convert xhrs js to ts #30935

wants to merge 4 commits into from

Conversation

jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Jan 23, 2025

Additional details

Converting server xhrs.js to typescript. There could be better types, but I didn't want to get too caught up in an area of code that I'm not super familiar with. Still attempting to have all references of mime be in TS files so we can upgrade the dep.

Steps to test

ts lint/checks + tests pass

How has the user experience changed?

N/A

PR Tasks

Copy link

cypress bot commented Jan 23, 2025

cypress    Run #60030

Run Properties:  status check passed Passed #60030  •  git commit 52e1368882: install mime in net-stubbing package
Project cypress
Branch Review convert-ts-2
Run status status check passed Passed #60030
Run duration 17m 41s
Commit git commit 52e1368882: install mime in net-stubbing package
Committer Jennifer Shehane
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 13
Tests that did not run due to a developer annotating a test with .skip  Pending 1099
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 26478
View all changes introduced in this branch ↗︎
UI Coverage  45.83%
  Untested elements 190  
  Tested elements 165  
Accessibility  92.54%
  Failed rules  3 critical   8 serious   2 moderate   2 minor
  Failed elements 888  

@jennifer-shehane jennifer-shehane changed the title chore: convert xhrs js to ts chore: convert xhrs js to ts [WIP] Jan 24, 2025
@@ -18,12 +19,43 @@ import type { CypressIncomingRequest } from '@packages/proxy'
import type { InterceptedRequest } from './intercepted-request'
import { caseInsensitiveGet, caseInsensitiveHas } from '../util'

// TODO: move this into net-stubbing once cy.route is removed
Copy link
Member Author

Choose a reason for hiding this comment

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

There was a note about moving this into net-stubbing once cy.route was removed, so I did that 🤷🏻‍♀️

import { expect } from 'chai'
import { join } from 'path'
import { readFileSync } from 'fs'

const imageBuffer = readFileSync(join(__dirname, '..', 'fixtures', 'cypress-logo.png'))

describe('net-stubbing util', () => {
describe('parseContentType', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

just moved the unit tests into net-stubbing with the function

@jennifer-shehane jennifer-shehane self-assigned this Jan 24, 2025
@jennifer-shehane jennifer-shehane changed the title chore: convert xhrs js to ts [WIP] chore: convert xhrs js to ts Jan 24, 2025
@AtofStryker AtofStryker self-requested a review January 24, 2025 20:06
import type { CyHttpMessages } from '../external-types'
import { getEncoding } from 'istextorbinary'

const debug = Debug('cypress:net-stubbing:server:util')
const htmlLikeRe = /<.+>[\s\S]+<\/.+>/

const isValidJSON = function (text) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const isValidJSON = function (text) {
const isValidJSON = function (text: unknown) {

}

export function parseContentType (response?: string) {
const ret = (type) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really get anything out of having this be its own function?

Suggested change
const ret = (type) => {
const ret = (type: string) => {

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.

2 participants