Skip to content

Commit d18878f

Browse files
sainthkhemilyrohrboughdavidmunechika
authored
chore: refactor cy funcs (#19080)
Co-authored-by: Emily Rohrbough <[email protected]> Co-authored-by: David Munechika <[email protected]>
1 parent 3a21ee4 commit d18878f

File tree

6 files changed

+1090
-1124
lines changed

6 files changed

+1090
-1124
lines changed

packages/driver/cypress/integration/cypress/command_queue_spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _ from 'lodash'
22
import $Command from '../../../src/cypress/command'
3-
import $CommandQueue from '../../../src/cypress/command_queue'
3+
import { CommandQueue } from '../../../src/cypress/command_queue'
44

55
const createCommand = (props = {}) => {
66
return $Command.create(_.extend({
@@ -23,14 +23,14 @@ const log = (props = {}) => {
2323
describe('src/cypress/command_queue', () => {
2424
let queue
2525
const state = () => {}
26-
const timeouts = { timeout () {} }
27-
const stability = { whenStable () {} }
26+
const timeout = () => {}
27+
const whenStable = () => {}
2828
const cleanup = () => {}
2929
const fail = () => {}
3030
const isCy = () => {}
3131

3232
beforeEach(() => {
33-
queue = $CommandQueue.create(state, timeouts, stability, cleanup, fail, isCy)
33+
queue = new CommandQueue(state, timeout, whenStable, cleanup, fail, isCy)
3434

3535
queue.add(createCommand({
3636
name: 'get',

packages/driver/cypress/integration/util/queue_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import Bluebird from 'bluebird'
22

3-
import $Queue from '../../../src/util/queue'
3+
import { Queue } from '../../../src/util/queue'
44

55
const ids = (queueables) => queueables.map((q) => q.id)
66

77
describe('src/util/queue', () => {
88
let queue
99

1010
beforeEach(() => {
11-
queue = $Queue.create([
11+
queue = new Queue([
1212
{ id: '1' },
1313
{ id: '2' },
1414
{ id: '3' },

packages/driver/src/cypress.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import browserInfo from './cypress/browser'
1414
import $scriptUtils from './cypress/script_utils'
1515

1616
import $Commands from './cypress/commands'
17-
import $Cy from './cypress/cy'
17+
import { $Cy } from './cypress/cy'
1818
import $dom from './dom'
1919
import $Downloads from './cypress/downloads'
2020
import $errorMessages from './cypress/error_messages'
@@ -209,12 +209,8 @@ class $Cypress {
209209
// or parsed. we have not received any custom commands
210210
// at this point
211211
onSpecWindow (specWindow, scripts) {
212-
const logFn = (...args) => {
213-
return this.log.apply(this, args)
214-
}
215-
216212
// create cy and expose globally
217-
this.cy = $Cy.create(specWindow, this, this.Cookies, this.state, this.config, logFn)
213+
this.cy = new $Cy(specWindow, this, this.Cookies, this.state, this.config)
218214
window.cy = this.cy
219215
this.isCy = this.cy.isCy
220216
this.log = $Log.create(this, this.cy, this.state, this.config)

0 commit comments

Comments
 (0)