Skip to content

Commit

Permalink
fix: set the context when overwriting .clock command (#19158)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Manuel <[email protected]>
Co-authored-by: Ryan Manuel <[email protected]>
  • Loading branch information
3 people authored Dec 2, 2021
1 parent 42dfb8a commit 4630ef4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions packages/driver/cypress/integration/commands/clock_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ describe('src/cy/commands/clock', () => {
})
})

it('overwrites without crashing', () => {
Cypress.Commands.overwrite('clock', (originalCommand, ...args) => {
return originalCommand(...args)
})

cy.clock()
})

context('errors', () => {
it('throws if now is not a number (or options object)', (done) => {
cy.on('fail', (err) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/commands/clock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function (Commands, Cypress, cy, state) {
return Commands.addAll({ type: 'utility' }, {
clock (subject, now, methods, options = {}) {
let userOptions = options
const ctx = this
const ctx = state('ctx')

if (clock) {
return clock
Expand Down

3 comments on commit 4630ef4

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 4630ef4 Dec 2, 2021

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/9.1.1/circle-develop-4630ef49d846de529e85372fe892fd6a537fe1a6/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 4630ef4 Dec 2, 2021

Choose a reason for hiding this comment

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

AppVeyor has built the win32 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/9.1.1/appveyor-develop-4630ef49d846de529e85372fe892fd6a537fe1a6/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 4630ef4 Dec 2, 2021

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/9.1.1/circle-develop-4630ef49d846de529e85372fe892fd6a537fe1a6/cypress.tgz

Please sign in to comment.