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: refactor cy funcs #19080

Merged
merged 24 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash'
import $Command from '../../../src/cypress/command'
import $CommandQueue from '../../../src/cypress/command_queue'
import { CommandQueue } from '../../../src/cypress/command_queue'

const createCommand = (props = {}) => {
return $Command.create(_.extend({
Expand All @@ -23,14 +23,14 @@ const log = (props = {}) => {
describe('src/cypress/command_queue', () => {
let queue
const state = () => {}
const timeouts = { timeout () {} }
const stability = { whenStable () {} }
const timeout = () => {}
const whenStable = () => {}
const cleanup = () => {}
const fail = () => {}
const isCy = () => {}

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

queue.add(createCommand({
name: 'get',
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/cypress/integration/util/queue_spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Bluebird from 'bluebird'

import $Queue from '../../../src/util/queue'
import { Queue } from '../../../src/util/queue'

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

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

beforeEach(() => {
queue = $Queue.create([
queue = new Queue([
{ id: '1' },
{ id: '2' },
{ id: '3' },
Expand Down
8 changes: 2 additions & 6 deletions packages/driver/src/cypress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import browserInfo from './cypress/browser'
import $scriptUtils from './cypress/script_utils'

import $Commands from './cypress/commands'
import $Cy from './cypress/cy'
import { $Cy } from './cypress/cy'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import { $Cy } from './cypress/cy'
import { Cy } from './cypress/cy'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The name of the internal class is $Cy, not Cy.

import $dom from './dom'
import $Downloads from './cypress/downloads'
import $errorMessages from './cypress/error_messages'
Expand Down Expand Up @@ -209,12 +209,8 @@ class $Cypress {
// or parsed. we have not received any custom commands
// at this point
onSpecWindow (specWindow, scripts) {
const logFn = (...args) => {
return this.log.apply(this, args)
}

// create cy and expose globally
this.cy = $Cy.create(specWindow, this, this.Cookies, this.state, this.config, logFn)
this.cy = new $Cy(specWindow, this, this.Cookies, this.state, this.config)
Copy link
Contributor

Choose a reason for hiding this comment

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

For curious reviewers, logFn isn't used by the constructor (or even the create function at this point) so it's safe to omit.

window.cy = this.cy
this.isCy = this.cy.isCy
this.log = $Log.create(this, this.cy, this.state, this.config)
Expand Down
Loading