Skip to content

Commit

Permalink
chore: add check-ts command to pkg/driver (#22912)
Browse files Browse the repository at this point in the history
Co-authored-by: Blue F <[email protected]>
Co-authored-by: Rachel <[email protected]>
Co-authored-by: Rachel <[email protected]>
  • Loading branch information
4 people authored Aug 15, 2022
1 parent e80e4e8 commit 0aa89fa
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 14 deletions.
7 changes: 6 additions & 1 deletion cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3073,7 +3073,12 @@ declare namespace Cypress {
* Takes ComponentDevServerOpts to track the signature of the devServerConfig for the provided `devServer`,
* so we have proper completion for `devServerConfig`
*/
type ConfigOptions<ComponentDevServerOpts = any> = Partial<UserConfigOptions<ComponentDevServerOpts>>
type ConfigOptions<ComponentDevServerOpts = any> = Partial<UserConfigOptions<ComponentDevServerOpts>> & {
/**
* Hosts mappings to IP addresses.
*/
hosts?: null | {[key: string]: string}
}

interface PluginConfigOptions extends ResolvedConfigOptions, RuntimeConfigOptions {
/**
Expand Down
3 changes: 2 additions & 1 deletion packages/driver/cypress/e2e/cypress/command_queue.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ describe('src/cypress/command_queue', () => {
const fail = () => {}
const isCy = () => true
const clearTimeout = () => {}
const setSubjectForChainer = () => {}

beforeEach(() => {
queue = new CommandQueue(state, timeout, whenStable, cleanup, fail, isCy, clearTimeout)
queue = new CommandQueue(state, timeout, whenStable, cleanup, fail, isCy, clearTimeout, setSubjectForChainer)

queue.add(createCommand({
name: 'get',
Expand Down
2 changes: 2 additions & 0 deletions packages/driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.0-development",
"private": true,
"scripts": {
"check-ts": "tsc --noEmit",
"clean-deps": "rimraf node_modules",
"cypress:open": "node ../../scripts/cypress open",
"cypress:run": "node ../../scripts/cypress run --spec \"cypress/e2e/*/*\",\"cypress/e2e/*/!(origin|sessions)/**/*\"",
Expand All @@ -28,6 +29,7 @@
"@sinonjs/fake-timers": "8.1.0",
"@types/chalk": "^2.2.0",
"@types/common-tags": "^1.8.0",
"@types/crypto-js": "4.1.1",
"@types/jquery.scrollto": "1.4.29",
"@types/mocha": "^8.0.3",
"@types/sinonjs__fake-timers": "8.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cross-origin/events/socket.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { client } from '@packages/socket'
import { client } from '@packages/socket/lib/browser'

export const handleSocketEvents = (Cypress) => {
const webSocket = client({
Expand Down
2 changes: 2 additions & 0 deletions packages/driver/src/cy/commands/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,8 @@ export default (Commands, Cypress, cy, state, config) => {
// throw an error, else we'd be in a endless loop,
// we also need to disable retries to prevent the endless loop
if (previouslyVisitedLocation) {
// _retries is `private`. We're not using `retries()` method here because it breaks some tests.
// @ts-ignore
$utils.getTestFromRunnable(state('runnable'))._retries = 0

const params = { remote, existing, originalUrl, previouslyVisitedLocation, log: options._log }
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/stability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const create = (Cypress: ICypress, state: StateFunc) => ({
state('anticipatingCrossOriginResponse', request)
},

whenStableOrAnticipatingCrossOriginResponse (fn, command?) {
whenStableOrAnticipatingCrossOriginResponse (fn, command?): Promise<any> {
const commandIsOrigin = command?.get('name') === 'origin'
const commandIsEndLogGroup = command?.get('name') === 'end-logGroup'

Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cypress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class $Cypress {
get: () => {
$errUtils.warnByPath('subject.state_subject_deprecated')

return cy.currentSubject()
return this.cy.currentSubject()
},
})

Expand Down
19 changes: 15 additions & 4 deletions packages/driver/src/cypress/command_queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,18 @@ export class CommandQueue extends Queue<$Command> {
fail: $Cy['fail']
isCy: $Cy['isCy']
clearTimeout: ITimeouts['clearTimeout']

constructor (state: StateFunc, timeout: $Cy['timeout'], stability: IStability, cleanup: $Cy['cleanup'], fail: $Cy['fail'], isCy: $Cy['isCy'], clearTimeout: ITimeouts['clearTimeout']) {
setSubjectForChainer: $Cy['setSubjectForChainer']

constructor (
state: StateFunc,
timeout: $Cy['timeout'],
stability: IStability,
cleanup: $Cy['cleanup'],
fail: $Cy['fail'],
isCy: $Cy['isCy'],
clearTimeout: ITimeouts['clearTimeout'],
setSubjectForChainer: $Cy['setSubjectForChainer'],
) {
super()
this.state = state
this.timeout = timeout
Expand All @@ -74,6 +84,7 @@ export class CommandQueue extends Queue<$Command> {
this.fail = fail
this.isCy = isCy
this.clearTimeout = clearTimeout
this.setSubjectForChainer = setSubjectForChainer
}

logs (filter) {
Expand Down Expand Up @@ -249,7 +260,7 @@ export class CommandQueue extends Queue<$Command> {
// we're finished with the current command so set it back to null
this.state('current', null)

cy.setSubjectForChainer(command.get('chainerId'), subject)
this.setSubjectForChainer(command.get('chainerId'), subject)

return subject
})
Expand Down Expand Up @@ -281,7 +292,7 @@ export class CommandQueue extends Queue<$Command> {

this.state('index', index + 1)

cy.setSubjectForChainer(command.get('chainerId'), command.get('subject'))
this.setSubjectForChainer(command.get('chainerId'), command.get('subject'))

Cypress.action('cy:skipped:command:end', command)

Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cypress/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default {
errProps: {
appendToStack: {
title: 'From Cypress Internals',
content: $stackUtils.stackWithoutMessage((new Error('add command internal stack')).stack),
content: $stackUtils.stackWithoutMessage((new Error('add command internal stack')).stack!),
} },
})
}
Expand Down
3 changes: 2 additions & 1 deletion packages/driver/src/cypress/cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export class $Cy extends EventEmitter2 implements ITimeouts, IStability, IAssert
this.onUncaughtException = this.onUncaughtException.bind(this)
this.setRunnable = this.setRunnable.bind(this)
this.cleanup = this.cleanup.bind(this)
this.setSubjectForChainer = this.setSubjectForChainer.bind(this)

// init traits

Expand Down Expand Up @@ -360,7 +361,7 @@ export class $Cy extends EventEmitter2 implements ITimeouts, IStability, IAssert

this.overrides = createOverrides(state, config, focused, snapshots)

this.queue = new CommandQueue(state, this.timeout, stability, this.cleanup, this.fail, this.isCy, this.clearTimeout)
this.queue = new CommandQueue(state, this.timeout, stability, this.cleanup, this.fail, this.isCy, this.clearTimeout, this.setSubjectForChainer)

setTopOnError(Cypress, this)

Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cypress/mocha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ const patchHookRetries = () => {
})

// so this error doesn't cause a retry
getTestFromRunnable(this)._retries = -1
getTestFromRunnable(this).retries(-1)

throw err
}
Expand Down
5 changes: 4 additions & 1 deletion packages/driver/src/cypress/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,10 @@ export default {
return
},

resumeAtTest (id, emissions: Emissions = {}) {
resumeAtTest (id, emissions: Emissions = {
started: {},
ended: {},
}) {
_resumedAtTestIndex = getTestIndexFromId(id)

_emissions = emissions
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "./../ts/tsconfig.json",
"compilerOptions": {
"target": "ES2016",
"lib": ["ES2018", "DOM", "DOM.Iterable"],
"lib": ["ES2018", "DOM", "DOM.Iterable", "ES2021.String"],
"module": "commonjs",
"allowJs": true,
"noImplicitAny": false,
Expand Down
2 changes: 2 additions & 0 deletions packages/server/lib/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const logException = Bluebird.method(function (this: any, err) {
.create(err)
.catch(() => {})
}

return
})

export const get = errors.get
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6429,6 +6429,11 @@
resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.10.tgz#61cc8469849e5bcdd0c7044122265c39cec10cf4"
integrity sha512-C7srjHiVG3Ey1nR6d511dtDkCEjxuN9W1HWAEjGq8kpcwmNM6JJkpC0xvabM7BXTG2wDq8Eu33iH9aQKa7IvLQ==

"@types/[email protected]":
version "4.1.1"
resolved "https://registry.yarnpkg.com/@types/crypto-js/-/crypto-js-4.1.1.tgz#602859584cecc91894eb23a4892f38cfa927890d"
integrity sha512-BG7fQKZ689HIoc5h+6D2Dgq1fABRa0RbBWKBd9SP/MVRVXROflpm5fhwyATX5duFmbStzyzyycPB8qUYKDH3NA==

"@types/[email protected]":
version "4.1.5"
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd"
Expand Down

4 comments on commit 0aa89fa

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 0aa89fa Aug 15, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.5.0/linux-x64/develop-0aa89fa5b347f50d7a1f4a5c3853f773101ab362/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 0aa89fa Aug 15, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.5.0/darwin-arm64/develop-0aa89fa5b347f50d7a1f4a5c3853f773101ab362/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 0aa89fa Aug 15, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.5.0/linux-arm64/develop-0aa89fa5b347f50d7a1f4a5c3853f773101ab362/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 0aa89fa Aug 15, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.5.0/darwin-x64/develop-0aa89fa5b347f50d7a1f4a5c3853f773101ab362/cypress.tgz

Please sign in to comment.