mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-23 07:39:52 -06:00
fix: set the context when overwriting .clock command (#19158)
Co-authored-by: Ryan Manuel <ryanm@cypress.io> Co-authored-by: Ryan Manuel <rfmanuel@gmail.com>
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user